-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infinite recursion when dispatching action in onEnter hook. #70
Comments
I'm seeing this issue, I originally commended on remix-run/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 |
I'm getting a similar issue with |
I moved away from use of |
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 |
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.The text was updated successfully, but these errors were encountered: