Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs Redux中间件在reducer之后被调用_Reactjs_Redux_React Redux_Redux Middleware - Fatal编程技术网

Reactjs Redux中间件在reducer之后被调用

Reactjs Redux中间件在reducer之后被调用,reactjs,redux,react-redux,redux-middleware,Reactjs,Redux,React Redux,Redux Middleware,我创建了如下中间件: export default store => next => action => { const res = next(action) console.log("Middleware", action.type) return res } 我的商店配置是: import { createBrowserHistory } from 'history'; import { applyMiddleware, compose, c

我创建了如下中间件:

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
);


我还有一个reducer,我在日志和调试器中看到reducer首先被调用,然后是中间件。关于我配置的错误有什么建议吗?

如果我没记错的话,在调用
next(action)
时正在调用reducer。将您的
控制台移动到上面。log
应该会给出您想要的日志顺序。

该死-您认为它在返回时被触发是对的