Steven Musumeche Steven Musumeche - 1 year ago 177
React JSX Question

Redirect to another route after submission success

I'm using redux-form and react-router. Redux-form provides a method called

which is called after successful submission. However, I don't have access to the router in that method.

How can I redirect to a new route using react-router after a successful submission?

Answer Source

I would suggest you use container component for this. Once your form is submitted, dispatch an action and in that action use browserHistory to change or replace the route.

//container code
function mapDispatchToProps(dispatch){
    onSubmit : () =>{


//action code
 function updateData(){
    //update state if needed
    browserHistory.push(//changed route)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download