Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

74
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda