Unclear docs: "onSuccess" behavior #7791
Unanswered
everdimension
asked this question in
General
Replies: 0 comments
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.
-
Hi!
I'm trying to understand the motivation to use the
onSuccessoption foruseMutationThe given description doesn't provide me with enough information.
Assumption
My initial assumption was the
onSuccesshandles an edge case:If
mutationFnresolves after the component has been unmounted, it will not be invoked. Therefore, it would be safe to call imperative UI code that's not crucial for the mutation, e.g. something likenavigateBack()after the mutation is done.I looked at the code and it seems that
onSuccessis always called aftermutationFn, so this assumption is false.Docs should remove guesswork
Therefore, I can only make other guesses as to why this helper exists. Ideally, this would be explained in the method description.
So far, I don't see why I can't call the same code I would call in
onSuccessinsidemutationFninstead.I assume the reason may have to do something with global code listening to
queryClientmutations, but I'm not sure.Let's add a more clear description?
Beta Was this translation helpful? Give feedback.
All reactions