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•10mo 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-goldOP•10mo 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•10mo 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-goldOP•10mo 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