I have 1 file that is calling component file with the mutation function, the submit function works well but I cant pass the result to the call function in the mutate response, is there anyway I can pass the mutation success response?
change-email.tsx
const AccountEmails: React.FC = () => { const { mutate: updateUserEmail, isLoading } = useUpdateUserEmailMutation(); const { data } = useUserQuery(); const { t } = useTranslation(); const { register, getValues, handleSubmit, formState: { errors }, } = useForm<UpdateUserType>({ defaultValues, }); function onSubmit(input: UpdateUserType) { updateUserEmail(input); // need to get response if error or succeed????? }
component updateEmail.tsx
import { useMutation } from "react-query";export interface UpdateUserType { email: string;}async function updateUserEmail(input: UpdateUserType) { return http.patch(API_ENDPOINTS.UPDATE_EMAIL, input);}export const useUpdateUserEmailMutation = () => { return useMutation((input: UpdateUserType) => updateUserEmail(input), { onSuccess: (data) => { console.log(data, "Update User Email success response"); }, onError: (data) => { console.log(data, "Update User Email error response"); }, });};
thank you!