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