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

Old Query Param Value Gets Rehydrated After Navigation #774

Closed
tariwiencke opened this issue Nov 18, 2024 · 4 comments · Fixed by #776
Closed

Old Query Param Value Gets Rehydrated After Navigation #774

tariwiencke opened this issue Nov 18, 2024 · 4 comments · Fixed by #776
Labels
adapters/next/app Uses the Next.js app router bug Something isn't working feature/useQueryStates released

Comments

@tariwiencke
Copy link

Context

What's your version of nuqs?

"nuqs": "^2.2.1",

What framework are you using?

  • ✅ Next.js (app router)

Which version of your framework are you using?

"next": "15.0.3", "react": "19.0.0-rc-66855b96-20241106",

Description

Screenshot 2024-11-18 at 22 55 23

When navigating pages with the link component the value of url state gets reset in url but when changing a different value of query params object the old value gets rehydrated.

Reproduction

CodeSandbox: https://codesandbox.io/p/github/tariwiencke/nuqs-bug/main?import=true

Steps to reproduce the behavior:

  1. Change values of both inputs
  2. Navigate with link component Go to Subpage
  3. Change value of one input
  4. Bug: old value of second input gets rehydrated and is not displayed in url
@tariwiencke tariwiencke added the bug Something isn't working label Nov 18, 2024
@franky47 franky47 added the adapters/next/app Uses the Next.js app router label Nov 19, 2024
@franky47 franky47 added this to the 🪵 Backlog milestone Nov 19, 2024
@franky47
Copy link
Member

Thanks for the report, I managed to reproduce it on the e2e test bench too, it looks like it's an issue only in useQueryStates: splitting the search params into individual useQueryState hooks doesn't show this behaviour.

I'll have a look and report back.

@franky47
Copy link
Member

franky47 commented Nov 19, 2024

I think I have a fix in #776, could you try this and let me know if it fixes the issue on your end please?

pnpm add https://pkg.pr.new/nuqs@776

@tariwiencke
Copy link
Author

That works just fine. Thanks.

@franky47
Copy link
Member

This was shipped in 2.2.2.

@franky47 franky47 removed this from the 🚀 Shipping next milestone Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adapters/next/app Uses the Next.js app router bug Something isn't working feature/useQueryStates released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants