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

76
Vistas
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
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