Created
April 17, 2022 19:20
-
-
Save sestok/60161feb50b216078d18f7a4b852be6b to your computer and use it in GitHub Desktop.
Avoid [Memory Leaks] in React by removing Listerners when unmounting components
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
useEffect(() => { | |
window.addEventListener("scroll", handleKeyUp); | |
return () => { | |
window.removeEventListener("scroll", handleKeyUp); | |
} | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment