5.0.0-alpha.6
My use-case is submitting a form. When the form is submitted, I do an API call with an asynchronous action and if the promise resolves, then I redirect to the newly created document.
Here's a very simplified version of the problem:
In a container,
// Url will change, action would be dispatched and the store updated but react-router won't be triggered
var Promise = require('bluebird');
[...]
function mapDispatchToProps(dispatch) {
return {
onSubmit: function() {
Promise.resolve().then(function() {
dispatch(require('react-router-redux').push('/login'));
});
});
};
}
// Without the promise, it works
var Promise = require('bluebird');
[...]
function mapDispatchToProps(dispatch) {
return {
onSubmit: function() {
dispatch(require('react-router-redux').push('/login'));
});
};
}
```js
// React-router triggers if another action modifies the store right after (even push)
var Promise = require('bluebird');
[...]
function mapDispatchToProps(dispatch) {
return {
onSubmit: function(formData) {
Promise.resolve().then(function() {
dispatch(require('react-router-redux').push('/login'));
dispatch(require('react-router-redux').push('/login')); // Or any other action modifying the store
});
});
};
}
Any idea why this is happening?
Most helpful comment
See this guide: https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/guides/blocked-updates.md