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

123
Views
Agregar detectores de eventos dinámicos en React

¿Hay alguna forma en la que pueda agregar listas de eventos dinámicas, que se activarán para URL específicas y pueden detectar qué eventos se llaman en esa URL específica?

Por ejemplo, mis aplicaciones de reacción tienen múltiples rutas y, fuera de esas rutas para rutas específicas, quiero ver qué acciones (por acciones me refiero a hacer clic en un botón, presionar una tecla, etc.) se están ejecutando y, en base a eso, quiero llamar a una API con la acción que está siendo llamado.

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Sí, agregue un detector de eventos en un useEffect (y límpielo en la función de limpieza de efectos) en el componente de esa ruta:

 function MyView() { React.useEffect(() => { const handler = e => console.log(e); window.addEventListener('click', handler); return () => window.removeEventListener('click', handler); }, []); return <>Hello!</>; } // Not shown: hooking MyView up to your router.

También puede usar un enlace de evento prefabricado como react-use 's 'useEvent' .

about 4 years ago · Santiago Gelvez 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!