“Error: You may not call store.getState() while the reducer is executing.”

后端 未结 10 1652
囚心锁ツ
囚心锁ツ 2020-12-07 21:41

I just upgraded my fully functional react-native app to Redux v4, but now I am getting the following error:

Error: Error: Error: Error: You may not call

10条回答
  •  隐瞒了意图╮
    2020-12-07 22:23

    I had the same error with a PWA build with polymer 3. The store.js also tried to use the redux dev tools which I had to deactivate:

    ...
    // Sets up a Chrome extension for time travel debugging.
    // See https://github.com/zalmoxisus/redux-devtools-extension for more information.
    //const devCompose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
    const devCompose =  compose;
    
    // Initializes the Redux store with a lazyReducerEnhancer (so that you can
    // lazily add reducers after the store has been created) and redux-thunk (so
    // that you can dispatch async actions). See the "Redux and state management"
    // section of the wiki for more details:
    // https://github.com/Polymer/pwa-starter-kit/wiki/4.-Redux-and-state-management
    export const store = createStore(
      state => state,
      devCompose(
        lazyReducerEnhancer(combineReducers),
        applyMiddleware(thunk))
    );
    ...
    

提交回复
热议问题