Skip to content

Commit 9ae2a1a

Browse files
committed
make returning a promise for optimistic updates more explicit
https://www.twitch.tv/videos/1829920965?t=1h56m2s
1 parent 92545cc commit 9ae2a1a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

docs/react/guides/optimistic-updates.md

+3-1
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)