reduxjs / redux

A JS library for predictable global state management
https://redux.js.org
MIT License
60.89k stars 15.27k forks source link

Problem With Redux's Store.dispatch Doesn't Get Updated #3714

Closed padlock98 closed 4 years ago

padlock98 commented 4 years ago

Bug Reports

What is the current behavior?

Upgrading meteor (from 1.4 to 1.7) and react (from 15.3.2 to 16.8.6).

Then I found my codes were unable to update/store using Store.dispatch(), the Store just not updated.

Steps to Reproduce

My ACTIONS file as below:

config.js

...
export default {
  load({Meteor, Store}) {
    return new Promise((resolve, reject) => {
      Meteor.call('variables.load', null, (err, data) => {
        if (err) {
          reject({_error: err.reason });
          return;
        }

console.log("************ Store (A) = "+JSON.stringify(Store.getState()))
        Store.dispatch({
          type: LOAD_CONFIG,
          data
        });

        resolve();
console.log("************ Store (B) = "+JSON.stringify(Store.getState()))
      });
    });
  },
...

What is the expected behavior?

Both the console.log() were having the following:

Store (A) = {"router":{"locationBeforeTransitions":{"pathname":"/settings/config","search":"","hash":"","action":"PUSH","key":"zif4ls","basename":"/crm","query":{}}},"form":{"config":{"syncErrors":{"reportLimit":"Required"}}},"loadingBar":{}}

Store (B) = {"router":{"locationBeforeTransitions":{"pathname":"/settings/config","search":"","hash":"","action":"PUSH","key":"zif4ls","basename":"/crm","query":{}}},"form":{"config":{"syncErrors":{"reportLimit":"Required"}}},"loadingBar":{}}

Which I do expect it will have something like "reportLimit":6 , which was confirmed to have loaded into the data variable. Instead, I was getting the following error in browser console:

Uncaught TypeError: Cannot read property 'data' of undefined

Environment Details

"react-redux": "^4.4.10"
"redux": "3.5.2"

Am using Meteor Atmosphere's ecmascript to compile, previous was using babel+webpack.

Is there anything wrong/breaking changes you could think of? As these codes had been working before the upgrade.

timdorr commented 4 years ago

The issue tracker here on GitHub is reserved for bug reports and feature requests. For usage questions (which is what I believe this is), please use Stack Overflow or Reactiflux where there are a lot more people ready to help you out. Thanks!

Please feel free to reply if you think this issue was closed prematurely.