Multiple Nested Routes in react-router-dom v4. You can use Switch component in router v4. I think this code shows the basic idea of using component.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <Router> <Switch> <Route path='/login' component={Login} /> <Route path='/about' component={About} /> <Home> <Route component={({ match }) => <div> <Route path='/page1' component={Page1} /> <Route path='/page2' component={Page2} /> <Route path='/page3' component={Page3} /> </div> }/> </Home> </Switch> |
1 2 3 4 5 6 7 8 9 | export default class Home extends Component { render() { return ( <div className="Home"> { this.props.children } </div> ) } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.