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

82
Visualizações
How to update default value as updated data using react hook form in Mongo DB

I try to update the values of a form, for this, I use a react hook form. When it is rendered first it shows the default value which was given previously. It works fine whenever I tried to change all the values. But when I only change a specific field it removes all other value from the element, and only update this field. enter image description here I want to update only specific fields without changing the previous value How can I do that?

const onSubmit = (data) => {
  axios.put(`http://localhost:4000/users/${id}`, data)
       .then(res => console.log("success"))
}

return (
  <div>
    <form onSubmit={handleSubmit(onSubmit)}>
      <label>Team 1</label>
      <input defaultValue={match.team1} {...register("team1")} /> <br />
      <label>Team 2</label>
      <input defaultValue={match.team2} {...register("team2")} /><br />
      <input type="submit" />
    </form>
  </div>
);
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