问题
I would like to ask if this is the proper way to redirect to another page after redux-form submit success:
const form = reduxForm({
form: 'HeroesCreateComponentForm',
validate,
onSubmitSuccess: () => {
console.log('onSubmitSuccess called (yes, yes I do get called');
browserHistory.push('/')
},
});
回答1:
Did you try using next approach?
react-router-redux
import {push} from 'react-router-redux';
onSubmitSuccess has dispatch function as second parameter. See Redux form. onSubmitSuccess
onSubmitSuccess : (result,dispatch) =>{
dispatch(push('/needed-route'))
}
来源:https://stackoverflow.com/questions/42272135/redirect-after-submit-success-redux-form