score:2

Accepted answer

that defeats the purpose of the switch and the router at the same time. from the docs:

renders the first child <route> or <redirect> that matches the location.

switch basically ensures there's only ever one component rendered in the router. for optimal results, keep your routes in one component, as there is rarely any need to nest them like you do. for example:

import { switch, route } from 'react-router'

<switch>
  <route exact path="/" component={main}/>
  <route path="/assets" component={assets}/>
  <route path="/templates" component={templates}/>
</switch>

so you define your routes in your app entry point let's say app.js. and that's it, if you want more routes, add them there. if you want nested routes, you nest by literally nesting it: <route path="/assets/:id/update" component={assetupdate} />. that's all there is to it.


Related Query

More Query from same tag