Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

React Type Mutation response feedback

$
0
0

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!


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>