很抱歉这个愚蠢的问题,但我不知道如何将我现有的redux商店定义与applyMiddleware结合起来.
这是我目前的工作代码:
const store = createStore( combineReducers({ ...reducers, routing: routerReducer }) )
我想以某种方式将这个中间件添加到我的商店定义中:
applyMiddleware(...thunk)
我的解决方案不起作用,我在Web浏览器中收到" TypeError:dbg is undefined ":
const store = createStore( applyMiddleware(...thunk), combineReducers({ ...reducers, routing: routerReducer }) )
你能帮我个忙吗?谢谢.
试试这个
createStore( combineReducers({ ...reducers, routing: routerReducer }), applyMiddleware(thunk) )
句法:
createStore(reducer,[preloadedState],[enhancer])
Enhancer
必须是最后一个参数 createStore()
从这里了解更多