【发布时间】:2019-11-13 12:18:16
【问题描述】:
在标记此内容之前,请注意我已检查过的重复项:
- How to dispatch a Redux action with a timeout?
- TypeError: middleware is not a function
- × TypeError: middleware is not a function
我正在尝试在我的 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
版本:
- redux:4.0.1
- redux-thunk:2.3.0
编辑:
堆栈跟踪指向applyMiddleware 函数,正如我直接从我进行的调用中的问题TypeError: middleware is not a function 一样。
【问题讨论】:
-
您能否详细说明该错误的来源?这是实际的运行时错误吗?打字稿错误?有堆栈跟踪吗?
-
@markerikson 已编辑
标签: redux redux-thunk redux-middleware