title: Why dashboard route is not accessible to me even if I am logged in?
body: <p>I am using private route in my app to access dashboard. if I am not logged in it worked correctly and redirect me to the sign in page. but even if I am logged in it does not gives access to dashboard. Here is my code.</p>
  <p><strong>App.js</strong></p>
  <pre><code>import React from 'react';
  import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
  import Home from './containers/Home';
  import Login from './containers/Login';
  import Dashboard from './containers/Dashboard';
  import PrivateRoute from './components/PrivateRoute';
  import { Provider } from 'react-redux';
  import store from './store';
  
  const App = () =&gt; (
    &lt;Provider store={store}&gt;
      &lt;Router&gt;
        &lt;Layout&gt;
            &lt;Switch&gt;
              &lt;Route exact path='/' component={Home} /&gt;
              &lt;PrivateRoute exact path='/dashboard' component={Dashboard} /&gt;
              &lt;Route exact path='/login' component={Login} /&gt;
            
   
            &lt;/Switch&gt;
        &lt;/Layout&gt;
      &lt;/Router&gt;
    &lt;/Provider&gt;
  );
  
  export default App;
  </code></pre>
  <p><strong>PrivateRoute.js</strong></p>
  <pre><code>import React from 'react';
  import { Route, Redirect } from 'react-router-dom';
  import { connect } from 'react-redux';
  import PropTypes from 'prop-types';
  const PrivateRoute = ({ component: Component, auth, ...rest }) =&gt; (
    &lt;Route
      {...rest}
      render={(props) =&gt; {
         if (!auth.isAuthenticated) {
           return &lt;Redirect to=&quot;/login&quot; /&gt;;
          
        } else {
          return &lt;Component {...props} /&gt;;
        }
      }}
    /&gt;
  );
  
  const mapStateToProps = (state) =&gt; ({
    auth: state.auth,
  });
  
  export default connect(mapStateToProps)(PrivateRoute);
  </code></pre>
  <p>And if I am logged in on react redux tool my states are these <img src="https://i.stack.imgur.com/HvC68.png" alt="State" /></p>
  <p>I noticed even if isAuthanticated becomes true after login but <strong>else</strong> part of privateRoutes.js never called</p>