Does invalidateQueries accept a list of query keys? #10613
-
Describe the bugHi , when I tried to invalidate multiple queries like this:
it’s not working ... it does not invalidate both queries so is there any solution to invalidate multiple query keys? Your minimal, reproducible exampleimport { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; function Example() { useQuery({ queryKey: ['queryKeyOne'], useQuery({ queryKey: ['queryKeyTwo'], const mutation = useMutation({ return ( Steps to reproduce
Expected behaviorBoth queries ['queryKeyOne'] and ['queryKeyTwo'] should be invalidated when calling queryClient.invalidateQueries({ queryKey: ['queryKeyOne', 'queryKeyTwo'] }); How often does this bug happen?Every time Screenshots or VideosNo response PlatformmacOS Tanstack Query adapter@tanstack/react-query TanStack Query versionTypeScript versionAdditional contextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
I don't believe it does. But it does do prefix matching. So let's say you have two query keys: key1 = ['pages', 'foo']
key2 = ['pages', 'bar']Then you can invalidate all pages with: client.invalidateQueries({ queryKey: ['pages'] }); |
Beta Was this translation helpful? Give feedback.
I don't believe it does. But it does do prefix matching. So let's say you have two query keys:
Then you can invalidate all pages with: