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