|
Download react-query/docs/framework/angular/guides/invalidations-from-mutations.md from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 995 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/docs/framework/angular/guides/invalidations-from-mutations.md
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/docs/framework/angular/guides/invalidations-from-mutations.md
-
curl -L -o invalidations-from-mutations.md https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/docs/framework/angular/guides/invalidations-from-mutations.md
995 Bytes
| id: invalidations-from-mutations | |
| title: Invalidations from Mutations | |
| ref: docs/framework/react/guides/invalidations-from-mutations.md | |
| replace: { 'useMutation': 'injectMutation', 'hook': 'function' } | |
| [//]: # 'Example' | |
| ```ts | |
| mutation = injectMutation(() => ({ | |
| mutationFn: postTodo, | |
| })) | |
| ``` | |
| [//]: # 'Example' | |
| [//]: # 'Example2' | |
| ```ts | |
| import { | |
| injectMutation, | |
| QueryClient, | |
| } from '@tanstack/angular-query-experimental' | |
| export class TodosComponent { | |
| queryClient = inject(QueryClient) | |
| // When this mutation succeeds, invalidate any queries with the `todos` or `reminders` query key | |
| mutation = injectMutation(() => ({ | |
| mutationFn: addTodo, | |
| onSuccess: () => { | |
| this.queryClient.invalidateQueries({ queryKey: ['todos'] }) | |
| this.queryClient.invalidateQueries({ queryKey: ['reminders'] }) | |
| }, | |
| })) | |
| } | |
| ``` | |
| [//]: # 'Example2' | |
| You can wire up your invalidations to happen using any of the callbacks available in the [`injectMutation` function](../mutations.md) | |