Pass information from onMutate to mutationFn
Is it possible to access the data returned by the onMutate function inside of the mutationFn function?
Context: I am using the onMutate function to do optimistic updates. While doing so, I append a little information to my object, which I would like to use when syncing with the server inside of the mutationFn function.
2 Replies
xenophobic-harlequin•3y ago
No i don't think that's currently possible
eager-peachOP•3y ago
I found a workaround but it's not very pretty:
1. In the
onMutate method I change the latest mutation and append this information:
2. Now the mutationFn has access to this appended state (it’s given this information as its argument)