theJuls theJuls - 1 year ago 72
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download