reactjs - Redirect to another route after submission success -
i'm using redux-form , react-router. redux-form provides method called onsubmitsuccess
called after successful submission. however, don't have access router in method.
how can redirect new route using react-router after successful submission?
i suggest use container component this. once form submitted, dispatch action , in action use browserhistory
change or replace route.
//container code function mapdispatchtoprops(dispatch){ return{ onsubmit : () =>{ dispatch(updatedata()) } } } //action code function updatedata(){ //update state if needed browserhistory.push(//changed route) }
Comments
Post a Comment