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

117
Views
Implement Array on Form Field Using Index and Spread Operator

I want to implement a form that can handle array data with dynamic field. I build that app with TypeScript.

But it gave me an error:

Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{ name: string; email: string; }'.ts(7053) 

I've searched google about that. I found a source that similar of my problem.

This is the part of code

const [formValues, setFormValues] = React.useState([{ name: "", email: "" }]);

  let handleChangeForm = (i: any, e: any) => {
    let newFormValues = [...formValues];
    newFormValues[i][e.target.name] = e.target.value;
    setFormValues(newFormValues);
  };

This is a link of that source: https://bapunawarsaddam.medium.com/add-and-remove-form-fields-dynamically-using-react-and-react-hooks-3b033c3c0bf5

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I change the code to solve a problem:

let handleChangeForm = (i: any, e: any) => {
    setFormValues(([i][e.target.name] = e.target.value));
};
about 4 years ago · Juan Pablo Isaza Report
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!