0

How to do this? For example i find this:

<Link to={{pathname: "/dialog", state: { detail: message }}}>
text
</Link>

but if i want display this.props.location.state, then write undefined.

kutirie
  • 583
  • 1
  • 4
  • 9

1 Answers1

0

Passing parameters

Configure your route path to accept named parameters (:id):

<Route path='/route/:id' exact component={MyComponent} />
Then you can pass URL parameters such as IDs in your link to:

<Link to={`route/foo`}>My route</Link>
You can access the parameter within your component via the match object:

const {id} = props.match.params

console.log(id) // "foo"
Prabhu
  • 1,057
  • 7
  • 13