
Please thoroughly read the Important Defaults before reading this guide
This caching example illustrates the story and lifecycle of:
Let's assume we are using the default cacheTime of 5 minutes and the default staleTime of 0.
useQuery('todos', fetchTodos) mounts.'todos' and fetchTodos as the unique identifiers for that cache.staleTime (defaults to 0, or immediately).useQuery('todos', fetchTodos) mounts elsewhere.useQuery('todos', fetchTodos) query are unmounted and no longer in use.cacheTime to delete and garbage collect the query (defaults to 5 minutes).useQuery('todos', fetchTodos) mounts. The query immediately returns the available cached value while the fetchTodos function is being run in the background to populate the query with a fresh value.useQuery('todos', fetchTodos) unmounts.useQuery('todos', fetchTodos) appear within 5 minutes.The best JavaScript newsletter! Delivered every Monday to over 76,000 devs.