title: React redirect after login not working
body: <p>I am trying using react-router and redux to build my react app. However, I am unable to get the url to route back to the dashboard post login. Can somebody please point out my mistakes?</p>
  
  <pre><code>const form = reduxForm({  
    form: 'login'
  });
  
  class Login extends Component {  
  
      handleFormSubmit(formProps) {
        this.props.loginUser(formProps);
        var token = cookie.load('token');
        if(token !== undefined){
          const location = this.props.location;
          if (location.state &amp;&amp; location.state.nextPathname) {
            browserHistory.push(location.state.nextPathname)
          } else {
            browserHistory.push('/')
          }
        }
      }
  
      renderAlert() {
      if(this.props.errorMessage) {
        return (
          &lt;div&gt;
            &lt;span&gt;&lt;strong&gt;Error!&lt;/strong&gt; Authentication error&lt;/span&gt;
          &lt;/div&gt;
        );
      }
    }
  
    render() {
      const { handleSubmit } = this.props;
  
      return (
        &lt;div&gt;
          &lt;form onSubmit={handleSubmit(this.handleFormSubmit.bind(this))}&gt;
          {this.renderAlert()}
            &lt;div&gt;
              &lt;label&gt;Username&lt;/label&gt;
              &lt;Field name="username" className="form-control" component="input" type="text" /&gt;
            &lt;/div&gt;
            &lt;div&gt;
              &lt;label&gt;Password&lt;/label&gt;
              &lt;Field name="password" className="form-control" component="input" type="password" /&gt;
            &lt;/div&gt;
            &lt;button type="submit" className="btn btn-primary submitButton"&gt;Login&lt;/button&gt;
          &lt;/form&gt;
        &lt;/div&gt;
      );
    }
  }
  
  function mapStateToProps(state) {  
    return {
      errorMessage: state.auth.error,
      message: state.auth.message
    };
  }
  
  const mapDispatchToProps = dispatch =&gt; ({
    loginUser: () =&gt;
      dispatch(loginUser);
  });
  
  export default connect(mapStateToProps, mapDispatchToProps)(form(Login));  
  </code></pre>
  
  <p>My <code>loginUser</code> function is as below:</p>
  
  <pre><code>export function loginUser({ username, password }) {
      return function(dispatch){
          axios.post(`${AUTH_URL}/obtain-auth-token/`, { username, password}, {
              headers: {
                  "X-CSRFToken": cookie.load('csrftoken')
              }
          })
              .then(response =&gt; {
                  if('token' in response.data){
                      cookie.save('token', response.data.token, {path: '/'});
                      dispatch({type: AUTH_USER});
                  } else{
                      console.log("Error condiction: " + response);
                      errorHandler(dispatch, error.response, AUTH_ERROR);
                  }
              })
              .catch((error) =&gt; {
                  errorHandler(dispatch, error.response, AUTH_ERROR);
              });
  
       }
  }
  </code></pre>
  
  <p>This is my first react-redux project so the mistake might be pretty elementary. Would really appreciate your help!</p>