React · Middle · Question 43 of 75
Why does TanStack Query, with default settings, refetch data when you return to the tab?
- ✓Correct answer:
staleTime: 0andrefetchOnWindowFocusby default - 2It's a known bug fixed in the next version
- 3The cache is fully cleared on every focus loss
Explanation
By default, TanStack Query aggressively keeps data up to date: it's considered stale immediately and refetched on mount, window focus and network reconnect. If data rarely changes, increase staleTime globally or for a specific query.