React Router 4 Nested Page


Here is an example of nested pages in react router. So you can make a template page and create nested pages with same template easily with react..


import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import { Route, BrowserRouter as Router, Switch} from 'react-router-dom';
import Template from './Template';
import ExamplePage1 from './Page1';
import ExamplePage2 from './Page2';
import Login from './Login';

      <Route exact path="/" component={Login}/>
      <Route exact path="/login" component={Login}/>
          <Route exact path="/page1" component={ExamplePage1}/>
          <Route exact path="/page2" component={ExamplePage2}/>


import React, { Component } from 'react';
import { withRouter } from 'react-router'
class Template extends Component {
  render() {
    return (
        <div className="content">


export default withRouter(Template);

You can find full example at :

By |2017-06-19T04:23:13+00:00June 19th, 2017|Uncategorized|0 Comments

About the Author:

Leave A Comment