Skip to content
Advertisement

How to combine dynamic and static routes in React

I need to combine dynamic and static routing in React. In my website i need to display bunch of products and they are displayed by using a dynamic routing <Route path={"/:products"}/> but every single product has his own ‘Install’ page but by running <Route path ={"/:products/install"}>Install</Route> it doesn’t work. In the product page i use link to go to /install route: <Link to="/SF43/install">SF34 install page</Link> How can i solve it?

Advertisement

Answer

You are missing exact:

<Route exact path="/:products"/>
<Route exact path ="/:products/install">Install</Route>
Advertisement