mutation callback called twice #1604
-
the callback inside useMutation seems to be called twice, once before the request has finished (or before sent, i am not sure because the state.isLoading is false for both calls) then the second time once the request is finished:
is this an intended behavior? If so, how do I prevent the double invocation? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
it seems
|
Beta Was this translation helpful? Give feedback.
The first callback is designed for GQty to collect the mutation contents, please only do query inputs and field selections there. GQty may call it multiple times for each fetch, because of how React rendering works. (
isLoading
is one of the factors to consider)onComplete
callback.onError
callback.Everything thrown from your query fetcher is considered a server error, so you may further customize how it behaves there.