Reputation: 1
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) =>
},
},
);
}
Upvotes: 0
Views: 391
Reputation: 20256
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?
Upvotes: 0