2016-10-28 34 views
1

我有一個React Redux應用程序,並試圖在我的某個reducer中偵聽react-router位置更改。我正在使用hashHistory,而不是browserHistory。在我的終極版devtools,我可以看到當位置改變它射擊動作:如何在redux reducer中偵聽反應路由器位置變化?

enter image description here

然而,在我減速,當我聽「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; 
    } 
} 

爲了在減速機中處理這個動作,我必須使用什麼?

回答

6

case 'LOCATION_CHANGE'更改爲case '@@router/LOCATION_CHANGE'

相關問題