-
Notifications
You must be signed in to change notification settings - Fork 97
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
react-router v6: warning You should call navigate() in a React.useEffect #211
Comments
Any updates? :) |
I am using the |
You could also check out the port of |
Hi there, support for React Router 6 has been added to v2.0.0-rc.0. Give it a shot and let me know if you still run into issues. See the changelog for migration info. |
can you be more specific? i can't see anything about setting URL parameter right on the first render i bumped into the same issue when wanting to change invalid URL params on the first render and this is my ugly HOTFIX w/
|
Similar issue here
|
i get the same warning also with the |
@pbeshai this seems to still be an issue. This isn't just a warning in practice - react-router warns, then ignores the navigate call - https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/hooks.tsx#L181-L187 The issue comes from the order in which react executes effects (which was a surprise to me, but makes sense). Also not sure if this order is actually guaranteed... Effects in the child get executed before effects in the parent (but in order within a component). Because of how this library uses I'm not sure if there's a good way to handle this in |
@pbeshai Can we reopen this issue? We're having the same problem, and have solved/worked around it by using a modified ReactRouter6Adapter which wraps the |
Used
RouteAdapter
example:https://github.com/pbeshai/use-query-params/blob/master/examples/react-router-6/src/index.js
#196 (comment)
My component code:
Getting an error:
And redirect doesn't work.
Temporary solution
How can I improve
RouteAdapter
to not implementfirstRenderDone
hack in every component I need redirect as soon as possible?The text was updated successfully, but these errors were encountered: