Redirect after submit success redux-form

混江龙づ霸主 提交于 2019-12-22 08:00:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!