-
I am adding Zustand and Nuqs to a new app. When adding Zustand, I notice local rerenders of all components that consume the getter/setter. I tried abstracting the Nuqs getter/setter into separate as recommended for Zustand in https://tkdodo.eu/blog/working-with-zustand but that does not help. #494 (comment) suggest that this is not needed ("The state updater function is also referentially stable across renders.") anyways. But how can I get rid of the unrelated rerenders? Video showing the rerenders (First no state, then Zustand added, then Nuqs added)
output.mp4 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
I'd have to look deeper into your example on a big screen next week, but one thing that comes to mind regarding re-renders is the change of behaviour in The documentation mentions that the state updater function is referentially stable, which was relevant before, but now unfortunately any change to the URL will cause all This is not a great experience, I'd have to see if we can implement a scoped Source: https://x.com/fortysevenfx/status/1796262844062986472 |
Beta Was this translation helpful? Give feedback.
-
A bit off topic but related: https://x.com/tkdodo/status/1818338443753136547 is talking about how React Router apparently has the same issue but Tanstack Query does not:
|
Beta Was this translation helpful? Give feedback.
Note: we're experimenting with "key isolation" that allows scoping re-renders only to the search params that did change, for supported frameworks, in #855 (unfortunately that doesn't include Next.js for which core changes would be necessary).