我创建了一个这样的中间件:
export default store => next => action => {
const res = next(action)
console.log("Middleware", action.type)
return res
}
我的商店配置是:
import { createBrowserHistory } from 'history';
import { applyMiddleware, compose, createStore } from 'redux';
import { routerMiddleware } from 'connected-react-router';
import middleware from './middleware'
import rootReducer from './reducers';
export const history = createBrowserHistory();
const defaultState = {};
const composeEnhancers =
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
}) : compose;
const enhancer = composeEnhancers(
applyMiddleware(middleware, routerMiddleware(history)),
);
export const store = createStore(
rootReducer(history),
defaultState,
enhancer
);
我还有一个减速器,我在日志和调试器中看到减速器首先被调用,然后是中间件。关于我配置错误的任何建议?