Created
April 13, 2019 08:14
-
-
Save ohansemmanuel/b0c213dd4e9a9ff417a68af86480cf80 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const EffectCleanup = () => { | |
| useEffect(() => { | |
| const clicked = () => console.log('window clicked') | |
| window.addEventListener('click', clicked) | |
| // return a clean-up function | |
| return () => { | |
| window.removeEventListener('click', clicked) | |
| } | |
| }, []) | |
| return <div> | |
| When you click the window you'll | |
| find a message logged to the console | |
| </div> | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment