-
-
Notifications
You must be signed in to change notification settings - Fork 250
style: Use useSyncExternalStore in the React adapter #723
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
style: Use useSyncExternalStore in the React adapter #723
Conversation
|
@bartlangelaan is attempting to deploy a commit to the 47ng Team on Vercel. A member of the Team first needs to authorize it. |
|
Thanks, wow this is so much cleaner! I had heard of useSyncExternalStore, but it didn't occur to me to use it here, it sounds like a perfect use-case. Great job! |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
I don't have time to test it today, so if you can't wait and want to test it, feel free! :-) |
|
Regarding the emitter, it's use is to make sure the |
commit: |
7a5fcba to
6b2e0a2
Compare
|
Hey, do you have some bandwidth to work on this again, or do you mind if I pick it up? |
|
I don't mind at all! I don't know when I will have time for this, so feel free! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 1 out of 1 changed files in this pull request and generated no suggestions.
Comments skipped due to low confidence (1)
packages/nuqs/src/adapters/react.ts:7
- Changing the emitter type from
{ update: URLSearchParams }to{ update: void }might cause issues if other parts of the codebase rely on theupdateevent carrying aURLSearchParamspayload.
const emitter = mitt<{ update: void }>()
|
Closing this as we do use uSES for the optimistic state in core now, although we might migrate away from it to prefer useOptimistic when we start only supporting React ^19 (probably in nuqs@^3). |
This utilizes the
useSyncExternalStorehook in the React adapter, which automatically takes care of rehydration errors.I'm unsure if it still works correctly, because this version does not use the emitter value anymore. It just gets it from the location every time. I will test it before marking it as ready.