Skip to content

Commit

Permalink
docs: make returning a promise for optimistic updates more explicit (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
JLarky authored Jun 7, 2023
1 parent b6000eb commit 6fb0807
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/react/guides/optimistic-updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ This is the simpler variant, as it doesn't interact with the cache directly.
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: async () => {
return await queryClient.invalidateQueries({ queryKey: ['todos'] })
},
})
```
[//]: # 'ExampleUI1'
Expand Down

0 comments on commit 6fb0807

Please sign in to comment.