State Management · Junior · Question 46 of 75
How does an RTK Query mutation make lists refetch after adding an item?
- ✓Correct answer: Queries declare
providesTags, the mutation declaresinvalidatesTags - 2You must call
window.location.reload()after the mutation - 3RTK Query refetches every endpoint after every mutation
Explanation
getPosts provides the Post tag and addPost invalidates it - active queries with that tag refetch automatically. It's the RTK Query counterpart of invalidateQueries in TanStack Query.