title: ReactJs - Warning when transitioning off page after successful login
body: <p>I have a straight foward login page which calls an api service to verify user login:</p>
  
  <p><strong>Login.js</strong></p>
  
  <pre><code>@connect(
    state =&gt; ({user: state.auth.user}),
    authActions)
  class Login extends React.Component {
  
    ......
  
    _handleSubmit = (event) =&gt; {
       .....
      this.props.login({username: username.value, password: password.value},
       (result) =&gt; {
        return result;
      });
      ......
    };
  
    render() {
      const {user, logout} = this.props;
      return (
        &lt;section&gt;
          {
            !user ?
              ... Show login page with submit button .....
  
              : this.context.router.replace('/')
          }
        &lt;/section&gt;
      )
    }
  };
  </code></pre>
  
  <p>While the component works as intended, I am receiving the warning:</p>
  
  <blockquote>
    <p><strong>Cannot update during an existing state transition (such as within
    <code>render</code> or another component's constructor). Render methods should be
    a pure function of props and state; constructor side-effects are an
    anti-pattern, but can be moved to <code>componentWillMount</code></strong></p>
  </blockquote>
  
  <p>I know the warning is due to the replace state of the router, but I do not know what would be the best way to prevent this warning and still accomplish the goal of moving away from the login page if the User exists.</p>
  
  <p>Any ideas?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Abdud Dayan Adeeb had the solution .....</p>
  
  <pre><code>  componentWillReceiveProps(nextProps ) {
      if (nextProps.user) this.context.router.replace('/')
    }
  </code></pre>