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

fix: React Router stale values after remount #887

Merged
merged 3 commits into from
Jan 31, 2025
Merged

Conversation

franky47
Copy link
Member

@franky47 franky47 commented Jan 31, 2025

It looks like useSearchParams' defaultInit argument is cached on the first call and not re-evaluated when mounting subsequent components, causing those re-mounted components to have a stale optimistic search params state.

Closes #881.

Copy link

vercel bot commented Jan 31, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nuqs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 31, 2025 10:03am

Looks like the useSearchParams defaultInit value is cached
in RR core, and is not evaluated on subsequent mounts.
@franky47 franky47 force-pushed the fix/881-rr-stale-values branch from 73b28b5 to 0885825 Compare January 31, 2025 10:00
Copy link

pkg-pr-new bot commented Jan 31, 2025

Open in Stackblitz

npm i https://pkg.pr.new/nuqs@887

commit: 0885825

@franky47 franky47 changed the title fix: RR stale values after remount fix: React Router stale values after remount Jan 31, 2025
@franky47 franky47 merged commit 8d98a7d into next Jan 31, 2025
27 checks passed
@franky47 franky47 deleted the fix/881-rr-stale-values branch January 31, 2025 14:41
Copy link

🎉 This PR is included in version 2.3.2-beta.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link

github-actions bot commented Feb 1, 2025

🎉 This PR is included in version 2.3.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@franky47 franky47 mentioned this pull request Feb 1, 2025
@franky47 franky47 removed this from the 🚀 Shipping next milestone Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stale values when accessing useQueryState in conditional components
1 participant