Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

72
Views
React Type Mutation response feedback

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!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I managed to fix it using :

isSuccess and isError variable and that will determine the success or error

thanks!

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!