Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

77
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda