Passing an object as prop in React-router Link
The "to
" property of Link
can accept an object so you can pass your props like this :
<Link to={
{
pathname: "/product/" + this.props.product.Id,
myCustomProps: product
}
}>
{Name}
</Link>
Then you should be able to access them in this.props.location.myCustomProps
I would suggest using redux
for retrieving the data. When you navigate to product route you can get the product
details by dispatching some action.
componentDidMount() {
let productId = this.props.match.params.Id;
this.props.actions.getProduct(productId);
}
The product
route should be connected with the the store.
Hope this helps.