I'm using react-router's <Link /> so that when a user clicks the link, myComponent is rendered.
My question is, how can I pass props into the myComponent from the Navigation component? This doesn't work, but I'm trying to pass a element.name prop from Navigation to myComponent.
class Navigation extends Component {
const items = store.getState().items.map((element, index) =>
<Link to={element.id} name={element.name}> element.id </Link>
)
render() {
return (
{items}
)
}
}
Here's the route setup & component setup:
<Route path=":id" component={myComponent} />
// I'd like to pass in props to be used here from the Navigation component, for example, a name prop passed through <Link />
class myCompnent extends Component {
render() {
return (
<div>
<p> hello {this.props.name} </p>
</div>
)
}
}