useMutation on success function not being called -
const { mutate } = useAddFAQPost()
const onSubmit = useCallback((event: React.ChangeEvent<FormEvent>) => {
event.preventDefault();
return mutate({ title, type } as FAQ), {
onSuccess: async (data: string, context: string) => {
console.log(data);
console.log('why not?');
},
onError: async (data: string, context: string) => {
console.log(data);
},
onSettled: () => {
//Some unmounting action.
//eg: if you have a form in a popup or modal -> call your close modal method here.
// onSettled will trigger once the mutation is done either its succeeds or errors out.
}
};
}, [title, type])
Run code snippet