Is it possible to catch location change event inside reducer while I am using connected-react-router?

193 views Asked by At

In my react app, I am using the connected-react-router library which is helpful to manage routing inside the redux part.

Today, I have faced a case that needs to capture location change event inside reducer. I was thinking it would be possible by catching the LOCATION_CHANGE action and actually I can catch location change event caused by history push action inside reducer something like this.

import { LOCATION_CHANGE } from 'connected-react-router'
...

const initialState = {
  ...
}

const handlers = {
  [LOCATION_CHANGE]: state => state.merge(initialState),
}

But the problem is I can't catch the events caused by the Link component. If anyone met this kind of need before and solved it, then please let me know.

0

There are 0 answers