Skip to content

fix(examples, docs): ignored promise from invalidate queries #8847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 26, 2025
Prev Previous commit
ci: apply automated fixes
  • Loading branch information
autofix-ci[bot] authored Mar 26, 2025
commit b8a3821f22b4777d6838b989c3f8aba041297617
7 changes: 4 additions & 3 deletions docs/framework/react/guides/optimistic-updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const addTodoMutation = useMutation({
mutationFn: (newTodo: string) => axios.post('/api/data', { text: newTodo }),
// make sure to _return_ the Promise from the query invalidation
// so that the mutation stays in `pending` state until the refetch is finished
onSettled: () => queryClient.invalidateQueries({ queryKey: ['todos'] })
onSettled: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
})

const { isPending, submittedAt, variables, mutate, isError } = addTodoMutation
Expand Down Expand Up @@ -119,7 +119,7 @@ useMutation({
queryClient.setQueryData(['todos'], context.previousTodos)
},
// Always refetch after error or success:
onSettled: () => queryClient.invalidateQueries({ queryKey: ['todos'] })
onSettled: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
})
```

Expand Down Expand Up @@ -155,7 +155,8 @@ useMutation({
)
},
// Always refetch after error or success:
onSettled: (newTodo) => queryClient.invalidateQueries({ queryKey: ['todos', newTodo.id] })
onSettled: (newTodo) =>
queryClient.invalidateQueries({ queryKey: ['todos', newTodo.id] }),
})
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function Example() {
}
},
// Always refetch after error or success:
onSettled: () => queryClient.invalidateQueries({ queryKey: ['todos'] })
onSettled: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
})

return (
Expand Down