2

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.

True Labs
  • 46
  • 5

0 Answers0