React-router: React-redux-router doesn't trigger re-render when pushed in promise

Created on 25 Apr 2017  路  1Comment  路  Source: ReactTraining/react-router

Version

5.0.0-alpha.6

Test Case

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?

>All comments

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jzimmek picture jzimmek  路  3Comments

maier-stefan picture maier-stefan  路  3Comments

tomatau picture tomatau  路  3Comments

ryansobol picture ryansobol  路  3Comments

winkler1 picture winkler1  路  3Comments