Refetching data with useQuery
Refetching is an important part of managing our server state. Sometimes, you need your data to be updated because your data has become stale or just because you haven’t interacted with your page in a while.
Manually or automatically, React Query supports and allows you to refetch your data.
In this section, we’ll see how it works and what automatic and manual ways you can leverage to refetch your data.
Automatic refetching
React Query has baked in a couple of options to make your life easier and keep your server state fresh. To do this, it automatically takes care of data refetching in certain cases.
Let’s look at the things that allow React Query to perform data refetching automatically.
Query keys
Query keys are used to identify your query.
When talking about query keys previously, I mentioned several times that we should include all of our query function dependencies as part of our query key. Why did I say...