title: Auth0 redirect loop after auth.loginWithRedirect() - @auth0/auth0-spa-js
body: <p>I'm currently switching the authentication of my (React) application from the Auth0 react SDK to the normal SPA SDK (as I don't like the way tokens are fetched in the react SDK)</p>
  <p>The issue I'm facing now is that when I sign in to the application I'm stuck in an endless redirection loop that is caused (I think) by the component below. Some context: the router uses protected routes that will redirect the user to the /login route that handles the authentication. Inside the component bellow <code>auth.isAuthenticated()</code> always returns false... That's why <code>auth.loginWithRedirect()</code> is called. But I can't see how to solve this...</p>
  <pre><code>const LoginRoute: React.FunctionComponent&lt;any&gt; = ({ ...props }) =&gt; {
    const { isLoggedIn, loading } = useSelector(userSelector);
    const dispatch = useDispatch();
  
    useEffect(() =&gt; {
      const handleAsyncLogin = async () =&gt; {
        const isAuthenticated = await auth.isAuthenticated();
        if (isAuthenticated) {
          // Auth0 says we are logged in, so we only need to store the user in the store
          dispatch(login());
        } else if (!!auth &amp;&amp; !loading) {
          // We are *not* logged in. Go to Auth0 login page.
          await auth?.loginWithRedirect();
        }
      };
      handleAsyncLogin();
    }, [dispatch, loading]);
  
    return (
      &lt;Route
        {...props}
        component={() =&gt; {
          if (isLoggedIn) {
            console.log(&quot;Is Logged In&quot;);
            // We are *definitely* logged in, go to projects
            return &lt;Redirect to=&quot;/questionsFromMe&quot; /&gt;;
          }
          if (loading) {
            return &lt;Loader /&gt;;
          }
          return &lt;div /&gt;;
        }}
      /&gt;
    );
  };
  </code></pre>
  <p>Please help me out! Thanks in advance.</p>