Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect after submit success redux-form

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('/')
    },
});
like image 624
Sydney Loteria Avatar asked Nov 09 '22 01:11

Sydney Loteria


1 Answers

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'))

}
like image 82
Arthur Avatar answered Nov 14 '22 23:11

Arthur