T
TanStack10mo ago
like-gold

Re-render 1 component but not another via the same queryKey?

I read that you can use select to subscribe to a sub-set of data, i.e I am assuming that when another component invokes invalidateQueries for the same queryKey, it shouldn't re-render the other component if the select returns a sub-set of data that did not change?
4 Replies
stormy-gold
stormy-gold10mo ago
Can confirm this works well. I'm using selects a lot to prevent table rerendering. Selecting individual values in cells. This is on data that is either polled, or streamed in multiple times per second. So constantly rewritten, only rerendered on select changes.
like-gold
like-goldOP10mo ago
Hmm doesn’t seem to work for me. Like I have two same query keys, one makes an update in a component, the other components select method returns an object with an ID and some other data. Both components are refetched
flat-fuchsia
flat-fuchsia10mo ago
can you show a reproduction please?If you return the same data from select (can be a new reference as it will be structurally shared), your component shouldn't re-render
like-gold
like-goldOP10mo ago
I’ll test more and then try to reproduce. It’s hard cuz it’s prod code so I’ll have to mock it a bit

Did you find this page helpful?