Skip to content

Commit 6fb0807

Browse files
authored
docs: make returning a promise for optimistic updates more explicit (#5485)
1 parent b6000eb commit 6fb0807

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

docs/react/guides/optimistic-updates.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ This is the simpler variant, as it doesn't interact with the cache directly.
1515
mutationFn: (newTodo: string) => axios.post('/api/data', { text: newTodo }),
1616
// make sure to _return_ the Promise from the query invalidation
1717
// so that the mutation stays in `pending` state until the refetch is finished
18-
onSettled: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
18+
onSettled: async () => {
19+
return await queryClient.invalidateQueries({ queryKey: ['todos'] })
20+
},
1921
})
2022
```
2123
[//]: # 'ExampleUI1'

0 commit comments

Comments
 (0)