Accepted answer

The Switch component will only render its first match.

The first Route that matches the path /users/10 is <Route path="/users" component={Users} />.

This means that even though you have a second Route that says the "10" should be a param called id, its ignoring it and treating it as the first Route does which has no params.

You can easily correct this behavior by using the exact prop on the first Route:

<Route exact path="/users" component={Users} />

This will instruct react-router to only match that route if the URL matches the path exactly, and will allow /users/10 to pass down to the Route you actually want it to match. Then you will have the params available that you expect.

Related Query

More Query from same tag