I am building an application that has a login screen and dashboard. When i successfully login i want my app to go to the dashboard but when i call a history.push('/dashboard'); in my ACTION(i think the history push will be called here after a promise). The URL changes but does not render the view.
My Login Component :
onSubmit(values){
    this.props.loginUser(values);
  }
render(){
return(
  <div>
    <form onSubmit={this.props.handleSubmit(this.onSubmit.bind(this))}>
      <Field
        label='Username'
        name='username'
        component={this.renderField}
        type="text"
      />
      <Field
        label='Password'
        name='password'
        component={this.renderField}
        type="password"
      />
      <button type="submit">Login</button>
    </form>
    {this.renderError()}
  </div>
);}}
    function mapStateToProps({profile}){
  return {profile};
}
export default reduxForm({
  validate,
  form:'LoginForm'
})(withRouter(connect(mapStateToProps,{loginUser})(Login)))
My Action :
export function loginUser(values){
  return dispatch => axios.post(`${ROOT_URL}verifyuser`,values)
    .then((response)=>{
      if(response.data.code == 'success'){
        dispatch(success(response.data),history.push('/dashboard'));
      }else{
        dispatch(failure(response.data));
      }
    })
    function success(response) { return {type:userConstants.LOGIN_SUCCESS,payload:response}; }
    function failure(response) { return { type: userConstants.LOGIN_FAILURE, payload:response } }
}
My Dashboard Component :
class Dashboard extends Component {
  render(){
    return(
      <div>Test</div>
    );
  }
}
MY routing
const App = () => (
  <Switch>
    <Route path="/dashboard" component={Dashboard}/>
    <Route exact path="/" component={Login} />
  </Switch>
)
ReactDOM.render(
  <Provider store={createStore(reducers,applyMiddleware(promise,thunk))}>
    <BrowserRouter>
      <App />
    </BrowserRouter>
  </Provider>
  , document.getElementById('root'));
 
    