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

75
Views
React Update/Edit Field not updating after mutation?

I have a same field for creating and updating the form using modal , the creation is working fine, while for the updating the latest changes are not updating , infact I am getting the previous value only , let me know where I am missing here .

Creation and Updating:

  const createVendor = async () => {
    setEditMode(false);
    const data = { contactPerson, contactNumber, email };
    try {
      const response = await addingVendor(data);
      setMessage(response.data.message);
      forceUpdate(), handleClose();
    } catch (error) {
      throw error;
    }
  };

const updateVendor = async () => {
    setEditMode(true);
    const data = { contactPerson, contactNumber, email };
    try {
      const response = await updatingVendor(vendorId, data);
      console.log(response);
      setMessage(response.data.message);
      forceUpdate(), handleClose();
    } catch (error) {
      throw error;
    }
  }; 

This is where I am triggering the modal for update:

 const [inputValue, setInputValue] = useState({
    contactPerson: '',
    contactNumber: '',
    email: '',
  });

      const showUpdateVendor = (data) => {
        setOpenUpdate(true);
        setInputValue({
          contactPerson: data.contactPerson,
          contactNumber: data.contactNumber,
          email: data.email,
        });
        setVendorId(data._id);
      };

and here is the modal component where i am passing via props:

<SideModal
  {...inputValue}
  open={openUpdate}
  onClose={() => setOpenUpdate(!openUpdate)}
  title='Update Vendor'
  handleChange={handleChange}
  editMode={editMode}
  onSubmit={updateVendor}
  isLoading={isupdatingVendor}
/>
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!