From the course: TanStack Query: Efficient Data Fetching and State Management

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Refetching query data

Refetching query data

- [Instructor] Let's take a quick look at this page in the documentation called important defaults. These defaults are as advertised, important. So basically we think about all of the data that has come from an external API as being stale. So what this means is that any stale queries are refetched automatically in the background when certain events occur, including new instances of the query mount. So when that hook is called, if the window is refocused, if the network is reconnected, or if the query is configured with a refetch interval. So polling is the idea where if we want to, we can set maybe every five seconds, every minute we can go to the server and refetch new data. Now, whether or not we want to do that is really dependent on what type of data it is. Is it scores for our favorite sports team? We probably want to load those more frequently. If it's data that doesn't change too much, we probably don't want to have those processes working in the background. Here in our GitHub…

Contents