title: Nested React Router
body: <p>I need some help to accomplish routing in ReactJS.
  I describe my problem and hope you can help me..</p>
  <p>I have famous index.js in this file and I call app.js from it</p>
  <pre><code>**index.js** 
  
  render(
    &lt;Provider store={store}&gt;
      &lt;App /&gt;
    &lt;/Provider&gt;,
    document.getElementById('app')
  );
  </code></pre>
  <p>inside app.js I wrote some code for routing as below :</p>
  <pre><code>**App.js**
  
  return (
          &lt;div&gt;
              {message &amp;&amp;
                  &lt;div className={`alert ${type}`}&gt;{message}&lt;/div&gt;
              }
              &lt;Router history={history}&gt;
                  &lt;div&gt;
                      &lt;PrivateRoute exact path=&quot;/&quot; component={Main} /&gt;
                      &lt;Route path=&quot;/login&quot; component={SignIn} /&gt;
                  &lt;/div&gt;
              &lt;/Router&gt;
          &lt;/div&gt;
      );
  </code></pre>
  <p>this work correctly and after login I redirect to Main.js</p>
  <p>and now my problem :</p>
  <p>I`ve written some route in Main.js page that all other pages must inherit from that. I mean all other page must have the skeleton of Main.js</p>
  <p>here is some code of Main.js</p>
  <pre><code>**Main.js**
  
  &lt;main className={classes.content}&gt;
      &lt;Link to=&quot;/HomePage&quot;&gt; HomePage&lt;/Link&gt;
      &lt;Link to=&quot;/Admin&quot;&gt; Admin &lt;/Link&gt;
      &lt;Link to=&quot;/Menus&quot;&gt; Menu &lt;/Link&gt;
      &lt;Link to=&quot;/Product&quot;&gt; Product &lt;/Link&gt;
      &lt;div className={classes.appBarSpacer} /&gt;
      &lt;Switch&gt;
          &lt;PrivateRoute path=&quot;/HomePage&quot; component={HomePage} /&gt;
          &lt;PrivateRoute path=&quot;/Admin&quot; component={Admin} /&gt;
          &lt;PrivateRoute path=&quot;/Menus&quot; component={Menus} /&gt;
          &lt;PrivateRoute path=&quot;/Product&quot; component={Product} /&gt;
      &lt;/Switch&gt;
  &lt;/main&gt;
  </code></pre>
  <p>unfortunately none of this routes works..
  I`m extremely confused because all of things seems right</p>