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, I get the following warning:
<Route
exact={true} path="/"
render={() => {
return <Home foo="bar"/>
}}
/>
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 and React Router?
My Home
component looks like this:
type homeType = {
foo: string
}
const Home: React.FC = ({foo}: homeType) => {
return <p>{foo}</p>
}
Home
component? – QoPfoo
in my example. – turtle