Skip to content
RED SAGSkills
medium10 pts · first answer countsreact-hooksmemory-leaks

Resize handler that runs many times

After opening and closing this panel a few times, every window resize runs the handler several times, even for panels that are already closed. What is the fix?

useEffect(() => {
  window.addEventListener('resize', () => setWidth(window.innerWidth))
}, [])
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions