Proxied Search Params for reduced re-renders #3943
ViewableGravy
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In Tanstack Query, when using
useQuery
, only the properties that you access are subscribed to, this means that your component will not re-render, when state you do not care about changes.In Tanstack Router, when using the
useSearch
hook, you have the option for aselect
function, however, when you are not using this, it's my understanding that you will get a re-render whenever a search param changes, even if you are not actually using that search param.Would it be possible (or correct me if it already does this by default), that when a select function is not provided, we instead return a proxy that only actually subscribes you to changes about the search parameters you destructured/access?
In so many cases at my work, I've noticed that we aren't necessarily doing some complex transformation in our components, but are just trying to get access to a particular search param without getting way too many re-renders for things on that route we do not care about.
We are sort of stuck on version 1.87 at my work due to a bug in newer versions, so It's entirely possible that this behavior is no longer the case in newer versions, but if not, is this something that Tanstack router would want implemented?
Beta Was this translation helpful? Give feedback.
All reactions