我试图在以下代码中使用中间件
import { thunk } from 'redux-thunk'
import {logger} from 'redux-logger'
import { createStore, applyMiddleware, compose } from 'redux'
export const store = createStore(rootReducer , defaultState , applyMiddleware(thunk,logger) )
但无论我使用什么中间件,我都会在浏览器中出现此错误:
它只有在我从applyMiddleware中删除所有中间件时才有效,如下所示:
export const store = createStore(rootReducer , defaultState , applyMiddleware() )
P.S。我使用以下库版本:
"react": "^15.2.1",
"react-dom": "^15.2.1",
"react-redux": "^4.4.1",
"redux": "^3.5.2",
"redux-thunk": "^2.1.0"
问题是什么?
答案 0 :(得分:2)
根据您的评论更新。尝试:
import thunk from 'redux-thunk';
import createLogger from 'redux-logger';
const logger = createLogger();
createStore(rootReducer , defaultState , applyMiddleware(thunk,logger)
强烈建议您参考您正在使用的库的文档。