调度`push`不会改变 React Redux Router 中的路由

Dispatching `push` does not change route in React Redux Router

我正在使用 React Redux Router 开发一个项目,我正在尝试更改页面。当组件调度 "push" 操作时,我看到 "@@router/LOCATION_CHANGE" 通过,但没有任何变化。

我也应用了 routerMiddleware,

import thunk from 'redux-thunk';
import { routerMiddleware } from 'react-router-redux';
import createHistory from 'history/createBrowserHistory'
import rootReducer from '../reducers';

export const history = createHistory();
const middleware = routerMiddleware(history)
export function configureStore(initialState) {
  return createStore(
    rootReducer,
    initialState,
    applyMiddleware(thunk),
    applyMiddleware(middleware)
  );
}

关于我做错了什么有什么想法吗?

applyMiddleware 需要一个中间件列表,所以你用错了: 请更改为:

export const history = createHistory();
const middleware = routerMiddleware(history)
export function configureStore(initialState) {
  return createStore(
    rootReducer,
    initialState,
    applyMiddleware(thunk,middleware)
  );
}

这也解释了为什么切换它们有效(商店收到了另一个中间件)。