【发布时间】:2016-10-28 20:19:16
【问题描述】:
我有一个 React Redux 应用程序,并试图在我的一个 reducer 中监听 react-router 位置变化。我使用的是hashHistory,而不是browserHistory。在我的 Redux devtools 中,我可以看到它在位置更改时触发了一个动作:
但是,在我的减速器中,当我侦听“LOCATION_CHANGE”时,它什么也捕捉不到。
import * as types from '../constants/actionTypes';
import objectAssign from 'object-assign';
import initialState from './initialState';
export default function listingsReducer(state = initialState.listings, action) {
switch (action.type) {
case 'LOCATION_CHANGE': {
console.log(action); //currently doesn't get into this case block
return state;
}
default:
return state;
}
}
我必须使用什么来在我的 reducer 中处理此操作?
【问题讨论】:
标签: javascript reactjs redux react-router