I have a route that looks like this, which renders just fine:
<Route
exact={true}
path="/"
render={() => {
return <Home />
}}
/>
If I add in any prop
<Route
exact={true}
path="/"
render={() => {
return <Home foo="bar" />
}}
/>
I get the following warning:
Type '{ foo: string; }' is not assignable to type 'IntrinsicAttributes & { children?: ReactNode; }'. Property 'foo' does not exist on type 'IntrinsicAttributes & { children?: ReactNode; }'. TS2322
How can I pass props to a component with Typescript?
My Home
component looks like this:
type homeType = {
foo: string
}
const Home: React.FC = ({ foo }: homeType) => {
return <p>{foo}</p>
}