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

185
Views
In React Query how can I write multiple mutate in a component?

I have two mutate in a component.


 // first mutate

 const { mutate, isLoading } = useMutation(apiService.redeemCodeProduct, {
    onSuccess: (data) => {
      setRedeemProduct(data);
      setRedeemProductID(data.id);
    },
    onError: (error) => {
      error.status === 404
        ? enqueueSnackbar("The product was not found", { variant: "error" })
        : enqueueSnackbar("An unknown error occurred", { variant: "error" });
      handleClose();
    },
  });

  const handleSubmit = (e) => {
    e.preventDefault();
    const urlRedeemCode = new URLSearchParams(redeemCode);
    mutate(urlRedeemCode);
  };


  // second mutate

  const { mutateRedeemSubmit } = useMutation(apiService.redeemCodeProductSubmit, {
    onSuccess: () => {
      enqueueSnackbar("The product was redeemed", { variant: "error" });
      handleClose();
    },
    onError: () => {
      enqueueSnackbar("An unknown error occurred", { variant: "error" });
    },
  });

  const handleSubmitRedeem = (e) => {
    e.preventDefault();
    mutateRedeemSubmit({redeemProductID, redeemCode})
  };


the problem is how can I write different mutate names in a component? My error is that mutate is not function

about 4 years ago · Juan Pablo Isaza
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!