connected-react-router: Uncaught TypeError: Cannot read property 'pathname' of undefined
This happens to me when using HMR (only after I chnage something I’m working on). Strange enough but this happend on any action

I did not notice such behaviour with previous versions.
From package.json:
{
"connected-react-router": "^4.2.1",
"react-router": "^4.1.1",
"react-router-dom": "^4.1.1",
}
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 23 (2 by maintainers)
The problem is you don’t have
routerin your state when HMR patch applying. You should wrap your rootReducer intoconnectRouterfunction.to:
I am getting this issue in my environment, but the suggested solution is not working in my case:
This is my setup:
My codes
Store.js
App.js
PageActions.js
PageReducer.js
RootReducer.js
Error
This is the error which I am getting:
More info
In my
HomePagecomponent, I have a call oninitiatePagewhich is available inPageAction.js. This is what clearly gives me this error and then what I get a blank page in the browser. When commenting out this line, everything went smooth, leaving a couple of warning messages which are pretty much same which you can see in the image above.The error indication is exactly the same as the original thread, but the suggested solution by @iceekey is not working in my case (as you can see, I have already added it in my code).
I really lost here. Any help on this issue is really appreciated. Thank you.
not sure if related but I was having similar if not identical error due to importing the wrong ConnectedRouter.
import { ConnectedRouter } from 'connected-react-router'instead ofimport { ConnectedRouter } from 'connected-react-router/immutable'@progammer-rkt
Did you ever resolve this issue? I’m having very similar issue and very similar code.
Seems like issue is resolved. Thanks, @iceekey