title: How to call Auth0 loginWithRedirect function in React useEffect without button clicking?
body: <p>In React app, I was going to implement Auth0 login like the following.
  When the user accesses the <code>/login</code>, it will check if the user is authenticated.</p>
  <p>Here is the code.</p>
  <pre><code>import React from 'react';
  import { useHistory } from &quot;react-router-dom&quot;;
  import { useAuth0 } from &quot;@auth0/auth0-react&quot;;
  import SplashScreen from &quot;src/components/SplashScreen&quot;;
  
  const LoginView = () =&gt; {
    const { loginWithRedirect, isAuthenticated } = useAuth0();
    const history = useHistory();
  
    React.useEffect(() =&gt; {
      if (isAuthenticated) {
        history.push(&quot;/explore&quot;);
      } else {
        loginWithRedirect();
      }
    }, [isAuthenticated])
  
    return &lt;SplashScreen /&gt;;
  };
  
  export default LoginView;
  
  </code></pre>
  <p>But when I log in from the Auth0 login page, I am redirected to the <code>/login</code> page of the React app, and it falls in looping indefinitely.
  I tried to log out the <code>isAuthenticated</code> value on the console like in the above code, but it is <code>false</code> even though I logged in on the Auth0 authentication page correctly.</p>
  <p>Please let me know how I can solve this issue.
  Thanks.</p>