title: Private Route Doesn't redirect to login Page
body: <p><strong>PrivateRoute does not redirect to the login page it is still public. What is the problem?
  this is the code...</strong></p>
  <pre><code>    import React, { useContext } from 'react'; 
      import { Route, Redirect } from 'react-router-dom';
      import AuthContext from '../context/auth/AuthContext';
          
      const PrivateRoute = ({ component: Component, ...rest }) =&gt; {  
          const { isAuthenticated, loading } = useContext(AuthContext);
          
          return (
              &lt;Route
                {...rest}
                render={props =&gt;
                  !isAuthenticated &amp;&amp; !loading ? (
                    &lt;Redirect to='/login' /&gt;
                  ) : (
                    &lt;Component {...props} /&gt;
                  )
                }
              /&gt;   
          ); 
      };
  </code></pre>