Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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>
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement