-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[Bug]: What's the updated way to navigate outside React Components? #11322
Comments
It depends on what APIs you are using ( There's an explanation of your options in #9422 (comment) and #9422 (comment) but the recommendation would be to get to |
Hi, thanks a lot for your response. One question I have - router object, that now I should be able to use it in my stores - How do I navigate with an addition of search params? second question - in this migration branch, since updated everything (including turning class components to function component), there's a case I couldn't figure out yet, where a routing happening twice, in a way that the element to render looks as if it completely renders twice immediately. |
You can just include them in the paramter: router.navigate('/path?a=1&b=2')
This sounds like a |
Again, many thanks. You helped a lot with these 2 comments and it seems like upgrading was finally completed! Warm suggestions for adding the RouterProvider solution to the official migration document. |
What version of React Router are you using?
migration to 6.22
Steps to Reproduce
Hello ,
I went through all documentation of migrating from v5 to v6, with "react-router-dom-v5-compat" library.
(here: #8753)
All went all, and I kept testing and checking everything still works all the way.
Expected Behavior
After removing compat lib, history lib and installing v6 - everything will work.
Actual Behavior
The step where things start failing is when deleting the compat lib and installing v6.
The reason for failure - nothing was said about how do we navigate outside React Components.
at first I deleted history lib as you said in the migration guide, but afterwards returned it, because I saw in the community couple of workarounds that are still using this lib.
and still - none of the community solutions worked for me (in what I found here nor in StackOverflow).
Please help me out here, I'm struggling with this migration for too long.
I really want it to success.
I need the ability to navigate at my Root Store (Mobx model layer in my case) already, and change navigations according to server state that changes.
currently working on React v17 (planning to migrate to v18 soon, if it's relevant somehow)
Will be most thankful for any help!
The text was updated successfully, but these errors were encountered: