Skip to content
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

RR7 -useQueryState() yields Error: useNavigate() may be used only in the context of a <Router> component. #831

Closed
ZipBrandon opened this issue Dec 29, 2024 · 4 comments
Labels
adapters/react-router Uses the React Router adapter

Comments

@ZipBrandon
Copy link

ZipBrandon commented Dec 29, 2024

Context

What's your version of nuqs?

"nuqs": "2.3.0-beta.2",

What framework are you using?

  • ✅ React Router

Which version of your framework are you using?

    "@react-router/node": "^7.1.1",
    "@react-router/serve": "^7.1.1",
    "react-router": "^7.1.1"
    "@react-router/dev": "^7.1.1",

Description

Error: useNavigate() may be used only in the context of a component. This comes from use of useQueryState.

Reproduction

https://github.com/ZipBrandon/rr7-nuqs

Example: Steps to reproduce the behavior:

  1. npm i && npm run dev
  2. Open the browser and get met with the error (which comes from use of useQueryState in welcome.tsx.
@ZipBrandon ZipBrandon added the bug Something isn't working label Dec 29, 2024
@franky47 franky47 added the adapters/react-router Uses the React Router adapter label Dec 29, 2024
@franky47 franky47 added this to the 🪵 Backlog milestone Dec 29, 2024
@franky47
Copy link
Member

Thanks for the repro! It's weird because it's the exact same setup that I have in the e2e tests for RRv7, and I don't see this message there.

I'll take a closer look tonight.

@franky47
Copy link
Member

I followed your instructions, and I cannot reproduce the error:

CleanShot 2024-12-29 at 20 59 21@2x

@franky47 franky47 added the cannot-reproduce Either no reproduction provided, or cannot reproduce with a minimal setup label Dec 29, 2024
@franky47 franky47 removed this from the 🪵 Backlog milestone Dec 29, 2024
@ZipBrandon
Copy link
Author

@franky47 Ahh, I'm using Node v22.12.0. I installed Node 20 and it works. Node 22+ is broken. It seems this is upstream remix-run/react-router#12475 . I installed Node v22.9.0 as in the reporter and it works as expected.

@franky47
Copy link
Member

Confirmed, I was running Node.js 22.11.0, which works. Switching to 22.12.0 shows the error message.

Going to close this since this is an upstream issue in React Router, thanks for figuring it out!

@franky47 franky47 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 29, 2024
@franky47 franky47 removed cannot-reproduce Either no reproduction provided, or cannot reproduce with a minimal setup bug Something isn't working labels Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adapters/react-router Uses the React Router adapter
Projects
None yet
Development

No branches or pull requests

2 participants