0

在标记这有重复之前,请注意我已经检查过:

我正在尝试同时在我的 Redux 商店上集成redux-thunk和使用替换。replaceReducer

基本上,我有一个地方:

const {createStore, applyMiddleware} = require('redux');
const thunk = require('redux-thunk');
createStore(function() {return {}}, applyMiddleware(thunk));
// also tried
// createStore(function() {return {}}, {}, applyMiddleware(thunk));

然后:

store.replaceReducer(someCombinedReducer);

现在,我通过createStore()线路触发了一个错误(所以在更换任何减速器之前)。

TypeError: middleware is not a function

版本:

  • 还原:4.0.1
  • redux-thunk:2.3.0

编辑:

堆栈跟踪指向的函数与这个问题TypeError: middleware is not a function directly from the call I make.applyMiddleware完全相同。

4

1 回答 1

1

经过一夜好眠和一些调整。

// thunk here is not undefined but and object
const thunk = require('redux-thunk');

应替换为:

const thunk = require('redux-thunk').default;
于 2019-07-03T09:06:49.620 回答