I'm trying to get the previous location from react router. I've set up a reducer to listen for @@router/LOCATION_CHANGE and store the current and new locations but this action doesn't seem to get fired anymore?
Reducer looks like this:
const initialState = {
previousLocation: null,
currentLocation: null,
};
const routerLocations = function (state = initialState, action) {
const newstate = { ...state };
switch (action.type) {
case "@@router/LOCATION_CHANGE":
newState.previousLocation = state.currentLocation;
newState.currentLocation = action.payload;
return newState
default:
return state;
}
}
export default routerLocations;
Is @@router/LOCATION_CHANGE the right thing to listen for?
I'm using
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"react-router-redux": "^4.0.8",