I need to write dedicated hook useMutation with onCompleted and parameter onMutationCompleted.
In file it uses like:
const [data] = useClearWorkerMutation({ onCompleted: onMutationCompleted });
I don't know how to put onCompleted
in this hook correctly.
export function useClearWorkerMutation() {
return useMutation<ClearWorkerMutationData, ClearWorkerMutationInput>(
CLEAR_WORKER_MUTATION,
{
onCompleted: (data) =>
},
},
);
}
Per the docs the function signature for useMutation
is:
function useMutation<TData = any, TVariables = OperationVariables>(
mutation: DocumentNode,
options?: MutationHookOptions<TData, TVariables>,
): MutationTuple<TData, TVariables> {}
If the only option is onCompleted
and you have some query then you would have:
useMutation(YOUR_MUTATION,{onCompleted: (data) => {…your function…})
It looks as if you're doing this correctly. Are you getting errors? Is your onCompleted
function not getting executed? What's not working?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.