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

110
Vistas
How add [event.target.name] in array selector - next.js app

I have two onChange handlers in my next app, and i would like split this two onChange handlers split in to one. Problem is i really dont know how make right syntax in array selector

// Working solution with two handlers

  const ticketPriceInreaseHandler = (
    e: { target: HTMLInputElement },
    index: number,
    index2: number
  ) => {
    const items = action.ticketsOnWave;

    items[index].wave[index2].price = e.target.value;

    setAction({
      ...action,
      ticketsOnWave: [...items],
    });
  };

  const ticketPiecesInreaseHandler = (
    e: { target: HTMLInputElement },
    index: number,
    index2: number
  ) => {
    const items = action.ticketsOnWave;

    items[index].wave[index2].pieces = e.target.value;

    setAction({
      ...action,
      ticketsOnWave: [...items],
    });
  };

I try it make one just handler like down on example but i getting always errors..

  const oneHandler = (
    e: { target: HTMLInputElement },
    index: number,
    index2: number
  ) => {
    const items = action.ticketsOnWave;

   items[index].wave[index2].event.taget.name = e.target.value;   // Here is problem 

       setAction({
      ...action,
      ticketsOnWave: [...items],
    });
  };

or i try it

    const nameOfField = e.target.name 

    items[index].wave[index2].nameOfField = e.target.value;   

// here i getting new in object field instead of field name from const nameOfField

What is a right syntax for this ? Thanks

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