web-dev-qa-db-ja.com

エラー:エラー:エラー:エラー:減速機の実行中にstore.getState()を呼び出すことはできません。 ????

完全に機能的なreact-nativeアプリをredux v4にアップグレードしたところですが、次のようなエラーが表示されます。

エラー:エラー:エラー:エラー:レデューサーの実行中にstore.getState()を呼び出すことはできません。レデューサーはすでに引数として状態を受け取っています。店からそれを読むのではなく一番上の減力剤からそれを渡しなさい。

私は問題を抱えているのではないでしょうか。私は他のものの中にたくさんのコンポーネントがあり、それぞれがconnect(mapStateToProps, mapDispatchToProps)(Component)を持っています。これが正しい実装方法ではないと思います。

どの方向でも大歓迎です!

スタックトレース:

    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]
62
bbrodsky

これはv2.16.0の新しいリリース of redux-devtools-extensionに関する問題です。

修正を待つ間に、いくつかの回避策があります...

  1. 元に戻す作業バージョンv2.15.5に戻します(Chromeの場合

  2. あるいは単に無効にするあなたのredux-devtool拡張子今のところ==。

    • ブラウザレベルで、またはあなたのコード(あなたがreduxストアを作成する場所)を通して

FYI:これはOPの質問を解決するものではありませんが、開発者が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はされました 公開されました

以前に拡張機能を無効にしたことがある人は、それを再度有効にしてあなたのredux devツールを2.16.0から2.16.2に更新してください pdate Redux Dev tools

188
Victor Le

私の場合は、 composeWithDevTools - chrome用のプラグインを削除する必要があります。

import { createStore, combineReducers, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';
import thunk from 'redux-thunk';

// const enhancer = composeWithDevTools(applyMiddleware(thunk))
const enhancer = applyMiddleware(thunk)

const store = createStore(reducers, enhancer);
23
Cong Dan Luong

私のプロジェクトでは。この問題はいつの日かどこからでもポップアップします。

私の解決策:Chrome拡張機能を無効にする - Redux Devtoolsそれからすべてが正常に戻ります。

だからこの種のエラーでは、問題を見つけるためにいくつかのブラウザでテストする必要があります。

10

クロム拡張を無効にするか、コードからcomposeWithDevToolを削除すると、簡単な解決策として機能します。しかし、アプリケーションの状態を追跡し、それを適切に管理するためには、拡張機能が必要であることを私たち全員が知っています。それで私は今日問題を作成しました、うまくいけばサポートしてください、reduxチームの誰かが私たちに戻ってくるでしょう。

または(クロムの)一時的な回避策を探しているなら、あなたはダウンロードすることができます https://github.com/zalmoxisus/redux-devtools-extension/releases/download/2.15.5/ extension.Zip をクリックして、いくつかのフォルダに展開します。

Chrome:// extensionsと入力し、左上から開発者モードをオンにして、Load Unpackedをクリックして、使用する抽出フォルダーを選択します。

問題: https://github.com/reduxjs/redux-devtools/issues/413

5

解決策私にはうまくいく

Redux DevツールのChrome拡張機能を無効にします。または、コードからロガーを削除します。

update:あなたのredux devツールを2.16.0から2.16.1に更新します Redux Devツールを更新します

5
sultan aslam

ポリマー3を使ったPWAビルドでも同じエラーが発生しました。store.jsも、非アクティブ化する必要があるredux devツールを使用しようとしました。

...
// 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))
);
...
2

Redux-thunk、react-native-router-fluxを使用しているときにも私と同じエラーが発生しました。レデューサーにタイムアウトを追加することで解決できました。

setTimeout(()=>{
                Actions.main();
                return state;
            },1)
2
Jose Kj

今すぐ修正する必要があります。あなたのredux devツールを2.16.0から2.16.1に更新してください。

https://github.com/zalmoxisus/redux-devtools-extension/issues/588#issuecomment-44239654

2
andrevenancio

これは私がしたことです:ちょうど私のstore.jsファイルからChrome Redux Devtools Extensionのための行をコメントしました。

....

 const store = createStore(
  rootReducer,
  initialState,
  compose(
    applyMiddleware(...middleware)
   ///This line--> window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__() 
  )
);

....

そして問題は1時間前に始まったばかりです。私たち全員が開発中にこの拡張が非常に便利であることを知っているので、当局からの本物の修正を待ちましょう。

2
Fawaz Abdulla