Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.

I suspect the problem is that I have numerous components inside others, each with their own connect(mapStateToProps, mapDispatchToProps)(Component) and I suppose this is not the correct way to implement it, though I am not sure the proper way to go about it.

Any direction is greatly appreciated!

Stack Trace:

    This error is located at:     in Connect(SideBarApp) (at SceneView.js:9)     in SceneView (at createTabNavigator.js:10)     in RCTView (at View.js:43)     in RCTView (at View.js:43)     in ResourceSavingScene (at createBottomTabNavigator.js:86)     in RCTView (at View.js:43)     in RCTView (at View.js:43)     in TabNavigationView (at createTabNavigator.js:127)     in NavigationView (at createNavigator.js:59)     in Navigator (at createNavigationContainer.js:376)     in NavigationContainer (at SceneView.js:9)     in SceneView (at SwitchView.js:12)     in SwitchView (at createNavigator.js:59)     in Navigator (at createNavigationContainer.js:376)     in NavigationContainer (at AppNavigator.js:36)     in App (created by Connect(App))     in Connect(App) (at index.ios.js:23)     in Provider (at index.ios.js:22)     in TheNewsApp (at renderApplication.js:32)     in RCTView (at View.js:43)     in RCTView (at View.js:43)     in AppContainer (at renderApplication.js:31)  This error is located at:     in NavigationContainer (at SceneView.js:9)     in SceneView (at SwitchView.js:12)     in SwitchView (at createNavigator.js:59)     in Navigator (at createNavigationContainer.js:376)     in NavigationContainer (at AppNavigator.js:36)     in App (created by Connect(App))     in Connect(App) (at index.ios.js:23)     in Provider (at index.ios.js:22)     in TheNewsApp (at renderApplication.js:32)     in RCTView (at View.js:43)     in RCTView (at View.js:43)     in AppContainer (at renderApplication.js:31)  This error is located at:     in NavigationContainer (at AppNavigator.js:36)     in App (created by Connect(App))     in Connect(App) (at index.ios.js:23)     in Provider (at index.ios.js:22)     in TheNewsApp (at renderApplication.js:32)     in RCTView (at View.js:43)     in RCTView (at View.js:43)     in AppContainer (at renderApplication.js:31) getState@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:79579:24 runComponentSelector@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:78896:56 initSelector@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:79019:28 Connect(SideBarApp)@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:78969:29 constructClassInstance@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:20826:32 updateClassComponent@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:22393:35 performUnitOfWork@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:24922:27 workLoop@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:24955:47 renderRoot@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:24988:21 performWorkOnRoot@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:25549:23 performWork@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:25481:30 performSyncWork@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:25456:20 requestWork@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:25362:26 scheduleWork@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:25224:28 enqueueSetState@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:20681:23 setState@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:2380:37 dispatch@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:80901:27 navigate@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:80517:24 nav@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:80470:44 combination@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:79810:38 dispatch@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:79628:38 setLoginStatus@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:112247:19 http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:112199:44 tryCallOne@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:8818:16 http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:8919:27 _callTimer@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:8162:17 _callImmediatesPass@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:8198:19 callImmediates@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:8417:33 __callImmediates@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:7741:32 http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:7580:34 __guard@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:7721:15 flushedQueue@http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:7579:21 flushedQueue@[native code] invokeCallbackAndReturnFlushedQueue@[native code] 
like image 969
bbrodsky Avatar asked Jul 24 '18 16:07

bbrodsky


1 Answers

It's an issue with the new v2.16.0 release of redux-devtools-extension.

Here's a couple of workaround while we wait for the fix...

  1. Revert back to the working version v2.15.5 (For Chrome)

    • Download https://github.com/zalmoxisus/redux-devtools-extension/releases/download/2.15.5/extension.zip
    • Extract the zip
    • Type chrome://extensions into the url and toggle on developer mode on the top right of the page.
    • The button Load Unpacked will appear. After clicking the button, select the extracted folder.
  2. Or just simply disable your redux-devtool extension for now.

    • either on the browser level or through your code(where you create the redux store)

FYI: this does not solve the OP's question but does solve the issue where developers are receiving the below error message starting 11/27/18.

Error: You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.


UPDATE

v2.16.2 has been released

For those who had previously disabled the extension, just re-enable it and Update your redux dev tools from 2.16.0 to 2.16.2 Update Redux Dev tools

like image 175
Victor Le Avatar answered Oct 08 '22 22:10

Victor Le