React · Middle · Question 45 of 75
Which queries does invalidateQueries({ queryKey: ['todos'] }) invalidate?
- ✓Correct answer: All queries whose key starts with
['todos'] - 2Only the query whose key is exactly
['todos'] - 3All queries in the app except inactive ones
Explanation
Matching is by key prefix by default, which makes hierarchical keys convenient: ['todos'] → ['todos', 'list', filters] → ['todos', 'detail', id]. Exact matching is enabled with exact: true. Keys are often moved into a factory (todoKeys.detail(id)).