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

501
Views
Error al ejecutar 'removeEventListener' en 'EventTarget': se requieren 2 argumentos, pero solo 1 presente

En mi aplicación React, tengo el siguiente useEffect y cleanup.

 useEffect(() => { if (pageLoad) { window.addEventListener('beforeunload', (e) => { localStorage.removeItem(SOME_KEY); }); return () => { window.removeEventListener('beforeunload'); } } }, [pageLoad]);

Sin embargo, me sale el siguiente error. ¿Hay algún problema con removeEventListener?

 Failed to execute 'removeEventListener' on 'EventTarget': 2 arguments required, but only 1 present
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede pasar la misma función para removeEventListener

 useEffect(() => { if (pageLoad) { const cb = (e) => { localStorage.removeItem(SOME_KEY); }; window.addEventListener("beforeunload", cb); return () => { window.removeEventListener("beforeunload", cb); }; } }, [pageLoad]);
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!