score:1

Accepted answer

You can make use of url path parameters to specify multiple paths matching the same route.

In your case the Route will look like

<Route path = "/test/:param/id-1" component={MyComponent}/>

In case you only want to match the /orders/ids-1 and /products/id-1, then you can make use of regex in the path param. react-router makes use of a path that path-to-regexp understands,

The relevant documentation of it is there with the react-router documentation

So you can use

  <Route path = "/test/(orders|products)/id-1" component={MyComponent}/>

Related Query

More Query from same tag