-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
v7: useNavigate()
may be used only in the context of a <Router>
component
#12399
Comments
This reverts commit 3c3de0d. Stay with major 6 for now. We face a problem described here: remix-run/react-router#12399 Also, upgrading v6 to v7 docs are absent (http 404). There is no urgency to consume this major update.
Having the very same issue. System Info
|
It looks like Whether or not this an issue with how we've setup the packages or is something that can easily be resolved by how you're setting up the |
For my reproduction repository above (and another testing site) the PR #12437 resolved our problem described in this issue. I know it's a stopgap but it works. So feel free to close the issue 👍 |
I see this was closed, but I'm still experiencing this issue with react-router 7.0.2 Surprisingly, it happens only with node 23.x, but works as expected with 20.x and 22.x |
Yep, I am also surprised by this. I opened #12475 last week and the team is aware. |
Seeing this with seems to be still a problem when accessing the hook from a component. |
I'm also seeing this, with:
|
@ZeldOcarina I'm going to keep this one closed since we have #12475 open now to track this issue |
Got it thanks! :) |
Note
If you have the same issue, please also visit #12475
I'm using React Router as a...
framework
Reproduction
https://github.com/lekoarts-demos/react-router-use-navigate-bug
For the reproduction to run you'll need a Clerk account to generate a pair of publishable key/secret key. On your Discord we have a shared channel with Clerk where I could also share credentials if you want, I didn't want to put them into a public repository.
System Info
Used Package Manager
pnpm
Expected Behavior
Hello!
I'm working for Clerk and I'm currently in the process of adding an SDK for React Router (we have an existing one for Remix). My WIP PR is here: clerk/javascript#4621
Unfortunately, I'm running into a problem with our current setup where I get the error:
The stacktrace leads to a custom hook in our SDK that uses
useNavigate()
. Our<ClerkProvider>
(that uses that hook) is used inside theroot.tsx
file and wrapping the<Outlet />
.In the commit lekoarts-demos/react-router-use-navigate-bug@ede0603 of the reproduction repository you can see the expected behavior. You use the
<ClerkProvider>
and our components/hooks have access to thereact-router
hooks.Actual Behavior
Unfortunately, the only way I got it to work was like this:
https://github.com/lekoarts-demos/react-router-use-navigate-bug/blob/783c37fb93f02baadf15103eddbaa91ca78fd9ce/app/root.tsx#L64-L79
By manually passing the hooks (or their return values) through the provider into our components. You can browse the reproduction value between the states of "actual behavior" and "expected behavior".
I've found #12368 and #11016 but
pnpm ls react-router
shows that only one instance ofreact-router
is used. Our SDK only defines it as a peerDependency.The text was updated successfully, but these errors were encountered: