title: how can i prevent access to routes in react js
body: <p>I am using react-redux for changing the state in my app.In my router page how can I route based on conditions.ie,If the user logged status is true then if i go to the login component it must redirect to the home component and the user logged status is false,if i go to the home component it must redirect to the login component.</p>
  
  <p><strong>routes.js</strong></p>
  
  <pre><code>const routes=() =&gt; (
      &lt;Router&gt;
          &lt;div&gt;
              &lt;Header /&gt;
                  &lt;Route exact path="/" render={ props =&gt;  &lt;div&gt;&lt;FirstConnectedComponent /&gt;&lt;SecondConnectedComponent /&gt;&lt;/div&gt;} /&gt;
                  &lt;Route path="/login" component={ requireAuth(Login) } /&gt;
                  &lt;Route path="/register" component={ UserReg } /&gt;
                  &lt;Route path="/home" component={ Home } /&gt;
              &lt;Footer /&gt;
          &lt;/div&gt;
      &lt;/Router&gt;
  
  )
  export default routes;
  </code></pre>