当调用createStore()时,我得到:TypeError:中间件不是函数

时间:2019-07-02 20:10:55

标签: redux redux-thunk redux-middleware

在标记之前有重复的注释,我已经检查过了:

我正在尝试集成set nocount on; declare @bill table (account_no tinyint, bill_cycle date); insert @bill (account_no, bill_cycle) values (1, '20190531'), (1, '20190430'), (2, '20190215'), (1, '20190531'); -- notice the duplicate for <1, May 31> declare @notrun table (account_no tinyint, bill_cycle date); insert @notrun (account_no, bill_cycle) values (1, '20190430'), (1, '20190630'), (1, '20190430'); -- notice the duplicate for <1, Apr 30> select account_no, bill_cycle from @bill except select account_no, bill_cycle from @notrun ; select bl.account_no, bl.bill_cycle from @bill as bl left join @notrun as nr on bl.account_no = nr.account_no and bl.bill_cycle = nr.bill_cycle where nr.account_no is null order by bl.account_no, bl.bill_cycle ; 并同时在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()

版本:

  • redux:4.0.1
  • redux-thunk:2.3.0

编辑:

直接在我进行的调用中,堆栈跟踪指向TypeError: middleware is not a function 函数,正像在此问题TypeError: middleware is not a function中一样。

1 个答案:

答案 0 :(得分:0)

经过一夜的睡眠和一些调整。

replaceAll()

应替换为:

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