Tylerlee12 Tylerlee12 - 1 year ago 396
React JSX Question

How do I listen for react-router location change in redux reducer?

I have a React Redux app, and am trying to listen for a

location change in one of my reducers. I am using
, not
. In my Redux devtools, I can see it is firing an action when the location changes:

enter image description here

However, in my reducer, when I listen for 'LOCATION_CHANGE', it doesn't catch anything.

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) {
console.log(action); //currently doesn't get into this case block
return state;
return state;

What do I have to use in order to handle this action in my reducer?

Answer Source

Change case 'LOCATION_CHANGE' to case '@@router/LOCATION_CHANGE'.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download