Out of the box, React Query is configured with aggressive but sane defaults. Sometimes these defaults can catch new users off guard or make learning/debugging difficult if they are unknown by the user. Keep them in mind as you continue to learn and use React Query:
useQuery
and similar hooks) will become "stale" immediately after they are resolved and will be refetched automatically in the background when they are rendered or used again. To change this, you can alter the default staleTime
for queries to something other than 0
milliseconds.cacheTime
for queries to something other than 1000 * 60 * 5
milliseconds.refetchOnWindowFocus
option in queries or the global config.retry
and retryDelay
options for queries to something other than 3
and the default exponential backoff function.config.isDataEqual
) only supports comparing JSON-compatible primitives. If you are dealing with any non-json compatible values in your query responses OR are seeing performance issues with the deep compare function, you should probably disable it (config.isDataEqual = () => false
) or customize it to better fit your needs.The latest TanStack news, articles, and resources, sent to your inbox.