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

139
Views
React hook form setValue is not getting updated correctly with removed properties

I got a list of Text fields like this and a delete button for each field.

{Object.keys(customProperties).map((item, index) => {
          return <Controller key={index}
            render={({ field }) => <TextField label={item} {...field} isDeleteBtn={true} onDeleteBtnClick={onDeleteField} />}
            name={customProperties.${item}}
            control={control}
          />;
        })}

My Delete code looks like

const onDeleteField = (customPropertyKey) => {
    const { ...properties } = customProperties;
    delete properties[customPropertyKey];
    setValue('customProperties',  properties);
  };

But the setValue('customProperties', properties); is removing the key but the values are got interchanged.

eg:  customProperties = {
      firstName: 'john',
    secondName: 'don'
}

After deleting firstName

it results in

customProperties = {
    secondName: 'John'
}

Any help please

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!