Concerning an unresolved issue (as a final opinion)
- Multiple nested routes in action-router-dom v4 mode
- How to nest routes in React Router v4?
I also get the same problem.
https://reacttraining.com/react-router/web/guides/quick-start contributes to react-router-dom
In addition, people are better off finding list down routes in a single file rather than inside.
Something mentioned: https://github.com/ReactTraining/react-router/tree/master/packages/react-router-config
Something working (mostly):
import * as React from 'react' import {BrowserRouter as Router, Route, Switch } from 'react-router-dom' export const Routes = () => ( <Router> <div> <Switch> <Route exact path="/login" component={Login}/> <MainApp path="/"> <Route path="/list" component={List}/> <Route path="/settings" component={Settings}/> </MainApp> <Route path="*" component={PageNotFound}/> </Switch> </div> </Router> )
Something doesn't work: site.com/SomeGarbagePath shows <MainApp> , I think.
<Route path="*" component={PageNotFound}/>
Update
/ - Home - parent of all (almost) /List - inside home /Settings - inside home /Login - standalone /Users - inside home, For now just showing itself. It has further pages. /User/123 - inside user with /:id /User/staticUser - inside user with static route /garbage - not a route defined (not working as expected)
reactjs react-router react-router-v4 react-router-dom
Masood
source share