I am having trouble passing props to my <Info/>
component. Everything is properly imported.
Here is my Router code in App.jsx
:
<BrowserRouter>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/user" element={<User />} />
{/* Also have tried: <Route path="/info" Component={Info} /> */}
<Route path="/info" element={(props) => <Info {...props} />} />
</Routes>
</BrowserRouter>
Here is where I use NavLink
to route to <Info/>
in another component.
<div>
{examples.map((example, i) => {
return (
<NavLink
to={{ pathname: "/info", state: { example: example } }}
key={i}
>
<div>I am the link!</div>
</NavLink>
);
})}
</div>
And here is my info component:
export const Info = (props) => {
const ex = props.location.state.example;
console.log(ex);
return (
<div>
:p
</div>
);
};
I've gotten a myriad of errors tinkering around with each of these... the above code produces the following error:
Functions are not valid as a React child. This may happen if you return a component instead of <Component />
from render. Or maybe you meant to call this function rather than return it.