1

I want to have a 'dynamic route' for a section of my app, which was done like this:

<Route path="path(/:id)" component={Component} />

So far this works, but in Component I would like to access the value of id because it changes a bunch of things depending on which it is. How can I do that?

theJuls
  • 6,788
  • 14
  • 73
  • 160

1 Answers1

1

In your component, you would access this via props.

this.props.params.id

Here is the guide from react-router that goes into more detail as well. https://github.com/reactjs/react-router-tutorial/tree/master/lessons/06-params

Kelly J Andrews
  • 5,083
  • 1
  • 19
  • 32