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

119
Vistas
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 Respuestas
Responde la pregunta

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