1
我有一個React Redux應用程序,並試圖在我的某個reducer中偵聽react-router
位置更改。我正在使用hashHistory
,而不是browserHistory
。在我的終極版devtools,我可以看到當位置改變它射擊動作:如何在redux reducer中偵聽反應路由器位置變化?
然而,在我減速,當我聽「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;
}
}
爲了在減速機中處理這個動作,我必須使用什麼?