我在文件middlewares / logger.js中有一个中间件,如下所示
const logger = store => next => action => {
console.log('dispatching', action)
let result = next(action)
console.log('next state', store.getState())
return result
}
导入并使用它是
import {logger} from './middlewares/logger'
...
let store = createStore(defaultReducers, applyMiddleware(logger));
我收到以下错误
未捕获TypeError:中间件不是函数 在eval(eval at(http://localhost:3000/static
)但是如果我将记录器放在我使用它的组件内并且它起作用
const logger = store => next => action => {
...
}
let store = createStore(defaultReducers, applyMiddleware(logger));
有关错误的任何建议吗?
感谢