Redux 的 applyMiddleware 无法渲染中间件
Redux's applyMiddleware cannot render middlewares
我正在尝试在以下代码中使用中间件
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"
可能是什么问题?
已根据您在下方的评论进行更新。尝试:
import thunk from 'redux-thunk';
import createLogger from 'redux-logger';
const logger = createLogger();
createStore(rootReducer , defaultState , applyMiddleware(thunk,logger)
强烈建议您参考所用库的文档。
我正在尝试在以下代码中使用中间件
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"
可能是什么问题?
已根据您在下方的评论进行更新。尝试:
import thunk from 'redux-thunk';
import createLogger from 'redux-logger';
const logger = createLogger();
createStore(rootReducer , defaultState , applyMiddleware(thunk,logger)
强烈建议您参考所用库的文档。