theJuls theJuls - 9 months ago 49
React JSX Question

How to access value of a routing parameter in react?

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?

Answer Source

In your component, you would access this via props.

Here is the guide from react-router that goes into more detail as well.