Post

If you have two useQuery with different staleTime, would you expect isStale returned from that useQuery to: * Change individually as each staleTime passes? * Change together when shortest staleTime has passed? * Have access to both of the above as separate isGloballyStale/isLocallyStale?

0 reposts3 likes

Thank you, that is another data point for what I definitely expect, that this mostly important in pretty niche cases. Can be important if you use isStale to show a manual refetch button etc though.

To be clear, this does not have to do with when the query refetches, the query would refetch and update both when the shortest staleTime had passed and options would dictate it (mount, window focus, network reconnect).

Actually, if a new component mounts with has a separate staleTime that is higher and has not passed yet, but an old visible component has a low staleTime that HAS passed, should the query refetch on mount? (Does today, but should it?)

I would expect it to follow each useQuery instance, same as refetchInterval etc. But Im unsure what to expect if you tried using the global queryClient to check whether or not the data is stale…

I think this is correct. I think there are two types of staleness, global and local. Local: Is it stale in this context? Global: Is it stale in any context?

An interesting quirk of this is that global staleness can go true->false without a refetch if the observer with the lowest staleTime unmounts, but I think this makes sense, no longer any need to revalidate on window focus for example.