React · Senior · Question 50 of 75

When does RTK Query remove data from its cache?

Explanation

RTK Query counts hook subscriptions for each endpoint and argument. When no subscribers remain, the keepUnusedDataFor timer starts; if something subscribes again in that time, the data comes from the cache. The TanStack Query counterpart is gcTime.

Further reading

Problem with a question

React · Senior · question 50

Test yourself

Take the React · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz