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

234
Views
Obtener el elemento en el que se hizo clic en el componente funcional en React

Soy nuevo en React y no puedo obtener el elemento en el que se hizo clic.

"esto" en el componente funcional no funciona

 function Test(data) { function getElement() { } return ( <div> {data.map((option: any, index: any) => ( <Text key={index} onClick={() => getElement()} > {option} </Text> ))} </div> ) }

hay varios elementos en los datos que quiero cambiar uno por uno, cambiando la clase 'activo', pero no es posible obtener el elemento en el que se hizo clic

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

0

Asegúrese de pasar el evento a su controlador de clics:

 function Test(data) { const handleClick = e => { const el = e.target console.log(el) } return ( <div> {data.map((option: any, index: any) => ( <Text key={index} onClick={handleClick} > {option} </Text> ))} </div> ) }
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!