React · Middle · Question 37 of 75

How does RTK Query know which data to refetch after a mutation?

Explanation

Tags link the query cache to mutations: getPosts provides [{ type: 'Post', id: 'LIST' }], and addPost invalidates the Post tag - active queries with this tag are refetched automatically. It's the counterpart of invalidateQueries in TanStack Query.

Further reading

Problem with a question

React · Middle · question 37

Test yourself

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

Take this quiz