reactjsreact-routerredux-formreact-router-v4react-redux-form

With React, redux-form, how to redirect after SubmitSuccess?


after my redux-form is submitted successfully, I want to redirect the user to a new URL.

Here's what I'm trying:

SignUp = reduxForm({
  form: 'SignUp',
  onSubmitSuccess: () => {
    console.log('onSubmitSuccess called');
    return <Redirect to="/hello" />
  }
})(SignUp);

The console log is happening when the form is successfully submitted. Any idea why React or redux-form is not redirecting?

i'm using:

"react-router-dom": "^4.1.1",
"react-router-redux": "^5.0.0-alpha.6",
"redux": "^3.6.0",
"redux-form": "^6.6.3",

Thanks


Solution

  • import { push } from 'react-router-redux';
    SignUp = reduxForm({
      form: 'SignUp',
      onSubmit: submit, // submit function must be return promise, for call   onSubmitSuccess
      onSubmitSuccess: (result, dispatch) => dispatch(push('/hello'))
    })(SignUp);