Replies: 1 comment
-
|
It’s because the 4th type parameter falls back to its default value. Take a look at also please put that in a typescript playground so it’s easier to help. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description:
I'm trying to implement an optimistic update using react-query's useMutation, where I temporarily update the userSession data and rollback on error. The mutation itself works, but TypeScript complains when I try to access context.snapshot inside onError.
Code:
Error:
Notes:
I've tried typing the return of onMutate, but the TypeScript error persists.
The expected behavior is that context.snapshot is available in onError to rollback the optimistic update.
Using React Query v5 and TypeScript.
Beta Was this translation helpful? Give feedback.
All reactions