У меня есть иерархия предметов.Допустим, это Страна -> Регион (просто пример).Поэтому я хотел бы иметь такие маршруты, как:
/countries/germany // list of regions
/countries/germany/1 // region details in Germany
/countries/germany/1/stores // list of stores in region #1 Germany
Вот корневой маршрут:
<Router history={history}>
<Switch>
<Route path='/countries' component={CountriesRoot} />
<Route><Redirect to='/countries' /></Route>
</Switch>
</Router>
И CountriesRoute
:
const CountriesRoot = ({ match }) => (
<Switch>
<Route exact path={match.url} component={CountriesList} />
<Route path={`${match.url}/:id(create|\d+)`} component={SingleCountryRoot} />
<Route><Redirect to={match.url} /></Route>
</Switch>
)
Видимо тампроблема с этим маршрутом:
<Route path={`${match.url}/:id(create|\d+)`} component={SingleCountryRoot} />
Маршрут /countries/germany/1
не работает.Я неправильно понимаю философию React Router?