03-10-2024, 05:56 AM
I've recently upgraded to React Router v4 from v3 and have been encountering issues when trying to programmatically navigate to different routes after a successful callback, particularly with Redux actions. In the previous version of React Router, I would use `browserHistory.push('/somepath')` to achieve this, but since they have removed `browserHistory` in v4, I am not quite sure about the right way to proceed.
Here's how my action creators looked in React Router v3 when making a post request and then redirecting:
Can anyone suggest the correct approach for redirecting in React Router v4 within Redux actions?
Here's how my action creators looked in React Router v3 when making a post request and then redirecting:
Code:
dispatch({
type: 'AUTH_USER'
});
// Redirect to the cart page
browserHistory.push('/cart'); // This doesn't work in React Router v4
});
}
Can anyone suggest the correct approach for redirecting in React Router v4 within Redux actions?