TanStackT
TanStack4mo ago
5 replies
brilliant-lime

Docs: Optimistic Updates issue

Hi everyone! I have an issue with optimistic docs example.

In docs it says the following:
To do this, useMutation's onMutate handler option allows you to return a value that will later be passed to both onError and onSettled handlers as the last argument. In most cases, it is most useful to pass a rollback function.


I read it as if I return data in onMutate function, onMutateResult will always be defined in onError | onSuccess | onSettled functions. And docs example suggests it also should work that way (first screenshot). But my result always can be undefined in every function (screenshot 2 and 3).

Would appreciate any help and clarification on this issue, thanks!
image.png
image.png
image.png
Was this page helpful?