Open Furizaa opened 8 years ago
I'm seeing this issue, I originally commended on rackt/react-router#1977 thinking it was in react-router but it actually seems it's specific to redux-router. Here's a screenshot of what I see in my console:
Those XHRs in the log are called from action dispatches that are triggered from an onEnter
defined in my route.
@Furizaa @thom-nic will reopen if this is still an issue.
I'm getting a similar issue with store.subscribe
which makes it execute twice on a single pushState/replaceState.. We're using v1.0.0-beta6
with hot-middleware/connect
I moved away from use of onEnter
to componentWillMount
& componentWillUpdate
in my page components which circumvented this issue. I don't know if onEnter
still has an issue or not.
I still get this onEnter issue.
@srahulprdxn would mind providing us with a gist?
Yea sure. I'll post it soon.
@Scarysize I am almost writing the same code as @Furizaa . So you can consider his comment for reference. I cannot provide you with my gist as I have moved with another solution which is just a work around.
I get infinite loop when trying to fire an action from history.listenBefore
, and strangely enough it occurs only during HMR process.
Not sure if this is the same problem, or different though. But seems it's the same, as described here: https://github.com/reactjs/react-router-redux/pull/30
To initially fill the state of my app on the server, components subscribe to the onEnter hook of their routes. In this static initialisation functions I dispatch some actions.
Now this code in redux-router kicks in:
https://github.com/rackt/redux-router/blob/master/src/client.js#L29
... and replaces the history again (calling onEnter again) ...
https://github.com/rackt/redux-router/blob/master/src/client.js#L37
... because it didn't had the chance to set
routerState
which initially is set toundefined
...https://github.com/rackt/redux-router/blob/master/src/client.js#L14
... resulting in an infinite loop.
Just setting
routerState
before thereplaceHistory
call fixes the loop - but everything still gets called twice.There has to be a way to initialise
routerState
with the correct state instead ofundefined
on the first call.