1

I want to display state from link, like this :

<Link to={{ pathname: '/courses/product/productlist', state: { fromDashboard: true }}}> Food & Treats </Link>

How can I display state in component ?

andika_kurniawan
  • 511
  • 4
  • 9
  • 20

1 Answers1

0

State will be available in location props inside component.

Access the state like this:

render(){
   console.log('state', this.props.location.state.fromDashboard);
   return (....)
}

Check the Doc for more details.

Mayank Shukla
  • 100,735
  • 18
  • 158
  • 142