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

165
Views
No se puede eliminar el detector de eventos en la aplicación de reacción

Así que hay una función que se parece a esto

 function eventListener(e) { if (!modalRef.current.contains(e.target)) { setOpenModal(false); } }

Y agrego un detector de eventos para escuchar burbujas de eventos en el cuerpo al inicio

 useEffect(() => { document.body.addEventListener("click", eventListener, true); return () => { document.body.removeEventListener("click", eventListener, true); }; }, []);

Y cuando el componente está escuchando el estado de burbuja

 useDidMountEffect(() => { console.log("hello the buble is", buble); if (buble) { document.body.addEventListener("click", eventListener, true); } else { console.log("I'm in false mode"); document.body.removeEventListener("click", eventListener, true); } }, [buble]);

Pero lamentablemente no puedo eliminarlo, prueba que no se está eliminando.

He leído estos sitios web

  1. https://www.edureka.co/community/71646/find-event-listeners-node-when-debugging-from-javascript-code

  2. No se pueden eliminar todos los detectores de eventos

También he usado la función de flecha pero no funcionó. Y también useDidMountEffect es un enlace personalizado para que la función no se ejecute al inicio, sino cuando la monto

about 4 years ago · Juan Pablo Isaza
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!