title: React-Router-4 routing from another component
body: <p>Is it possible to route a component from another component?</p>
  
  <p>So normally it would be done like below</p>
  
  <pre><code>&lt;NavLink to="/link"&gt;link&lt;/NavLink&gt;
  &lt;NavLink to="/anotherLink"&gt;link &lt;/NavLink&gt;
  &lt;Switch&gt;
      &lt;Route exact path="/link" component={linkComponent}/&gt;
      &lt;Route path="/anotherLink" component={anotherLinkComponent}/&gt;
  &lt;/Switch&gt;
  </code></pre>
  
  <p>but is it possible to have NavLink in one component which is loaded in the main component then route from the main component? So have <code>NavLink</code> in one component and have <code>Route</code> in the main component. </p>
  
  <p>The Nav component</p>
  
  <pre><code>export default class Nav extends Component {
      render() {
          return (
              &lt;nav className="navigation"&gt;
                  &lt;ul className="nav-container"&gt;
                      &lt;li&gt;
                          &lt;NavLink to="/" className="nav-title"&gt;
                              First Page
                          &lt;/NavLink&gt;
                      &lt;/li&gt;
                      &lt;li&gt;
                          &lt;NavLink to="second-page" className="nav-title"&gt;
                              Second Page
                          &lt;/NavLink&gt;
                      &lt;/li&gt;
                      &lt;li&gt;
                          &lt;NavLink to="third-page" className="nav-title"&gt;
                              Third Page
                          &lt;/NavLink&gt;
                      &lt;/li&gt;
                  &lt;/ul&gt;
                  &lt;div className="nav-decoration"&gt;
  
                  &lt;/div&gt;
              &lt;/nav&gt;
          )
      }
  }
  </code></pre>
  
  <p>The App component</p>
  
  <pre><code>import Nav from 'whateverthepath';
  
  export default class App extends Component {
  
      render() {
          return (
              &lt;div&gt;
                  &lt;Nav/&gt;
                  &lt;Switch&gt;
                      &lt;Route exact path="/" component={Firstpage}/&gt;
                      &lt;Route path="/secondpage" component={Secondpage}/&gt;
  
                  &lt;/Switch&gt;
              &lt;/div&gt;
          )
      }
  }
  </code></pre>
  
  <p>All the appropriate React imports are done</p>