-
Pretty sure a lot of people have already asked about this but since I have read all the posts and my code still isn't working, I would like to ask for some help. I am currently using v4. I think I got everything right. mutationKey has to be a string array. mutationFn only takes one input. I still don't understand what went wrong. I appreciate any help.
Here is the full function just in case: const postMutation = useMutation({
mutationKey: ["postMutation"],
mutationFn: (input) => props.isAdd ? props.postFunction(input) : props.postFunction(props.fieldItems.id, input),
onMutate: () => {
setModalLoading(true);
},
onSuccess: (data) => {
setModalLoading(false);
props.refetchFunction();
handleCancel();
},
onError: (err: any) => console.log(`Submit Error: ${err}`)
}); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
Beta Was this translation helpful? Give feedback.
input
is untyped. You need to add types toinput
of themutationFn
. Note that the error messages should get a lot better with v5 because there we don't have overloads anymore.