Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

invalidations-from-mutations.md

24 lines601 Bytes

1---
2id: invalidations-from-mutations
3title: Invalidations from Mutations
4ref: docs/framework/react/guides/invalidations-from-mutations.md
5---
6​
7[//]: # 'Example2'
8​
9```tsx
10import { useMutation, useQueryClient } from '@tanstack/vue-query'
11​
12const queryClient = useQueryClient()
13​
14// When this mutation succeeds, invalidate any queries with the `todos` or `reminders` query key
15const mutation = useMutation({
16 mutationFn: addTodo,
17 onSuccess: () => {
18 queryClient.invalidateQueries({ queryKey: ['todos'] })
19 queryClient.invalidateQueries({ queryKey: ['reminders'] })
20 },
21})
22```
23​
24[//]: # 'Example2'