I'm new to TypeScript and trying to understand how to convert my React Hooks code to be typed. At the moment, I'm getting the following error:
Property 'openMenu' does not exist on type '{ children?: ReactNode; }'
Property 'toggle' does not exist on type '{ children?: ReactNode; }'
Property 'slidein' does not exist on type '{ children?: ReactNode; }'
This is my code:
const Menu: FunctionComponent = ({ openMenu, toggle, slidein }) => {
return (
<>
<div className={`menu ${toggle}`} onClick={openMenu}>
<div className="bar1"></div>
<div className="bar2"></div>
<div className="bar3"></div>
</div>
<div className={`expand ${slidein}`}>
<ul>
<li>
<Link to="/" onClick={openMenu}>
List
</Link>
</li>
<li>
<Link to="/add-user" onClick={openMenu}>
Add User
</Link>
</li>
<li>Add Climb</li>
</ul>
</div>
</>
);
};
export default Menu;
The props are being sent in from the parent App.js file, which would normally be fine, but TypeScript doesn't seem to like this. I've tried adding a type next to each prop, but that doesn't solve the issue either.
package.json
...
"source-map-loader": "^0.2.4",
"ts-loader": "^6.1.2",
"typescript": "^3.6.3",
...