Skip to content

Commit

Permalink
make returning a promise for optimistic updates more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
JLarky committed Jun 6, 2023
1 parent 92545cc commit 9ae2a1a
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 9ae2a1a

Please sign in to comment.