title: Why do I get the "Maximum update depth exceeded" error?
body: <p>After I added a check for an authorized user in routes, I started getting an infinite re-render error.</p>
  <p>App.js:</p>
  <pre><code>function App(props) {
  
      useEffect(() =&gt; props.checkUserToken() , []); // action проверяющий, есть ли JWT в localStorage, если да, то меняет props.isLogin на true
    
      return (
          &lt;div className=&quot;d-flex align-items-center justify-content-center&quot;&gt;
              &lt;Switch&gt;
                  &lt;Route path='/authorization'
                         render={props =&gt; !props.isLogin ? &lt;Login {...props} /&gt; : &lt;Redirect to='/main' /&gt;}
                  /&gt;
  
                  &lt;Route path='/main'
                         render={props =&gt; props.isLogin ? &lt;MainPage {...props} /&gt; : &lt;Redirect to='/authorization' /&gt;}
                  /&gt;
                  &lt;Route
                      render={props =&gt; &lt;Redirect to={props.isLogin ? '/main' : '/authorization'} /&gt;}
                  /&gt;
              &lt;/Switch&gt;
              {
                  props.loading &amp;&amp; &lt;Loading /&gt;
              }
          &lt;/div&gt;
      )
  }
  </code></pre>
  <p>Here's what the redux-logger outputs:</p>
  <p><a href="https://i.stack.imgur.com/5Bm4Y.png" rel="nofollow noreferrer">Here's what the redux-logger outputs</a></p>
  <p>First, action &quot;CHECK_TOKEN&quot; is called (don't pay attention to persist), which is listened to by the Saga and, depending on the result of the check, it calls action &quot;TOKEN_EXIST&quot;, which changes isLogin to true in theory, then the App should re-render, again &quot;go&quot; to the authorization route and redirect to main, but an error POPs up.</p>
  <p>At first I thought it was about checking the token, so I commented on the hook, re-logged in, but everything was repeated, authorization was successful, data was received, isLogin became true, but again this error came out.</p>
  <p>Debugger and console.log do not work if you put them in MainPage, in action and sagas, I am also sure, because they all worked perfectly (and still work), until I changed the routes (made a check)</p>
  <ul>
  <li>as I wrote above, this error only POPs up when isLogin changes to true and a redirect should occur.</li>
  </ul>
  <p>Full error code:</p>
  <p><a href="https://i.stack.imgur.com/ThU3Q.png" rel="nofollow noreferrer">Full error code</a></p>
  <p>So what is the problem and how do I fix this error? Thank you in advance for any help!</p>