SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const EffectCleanup = () => {
  2.   useEffect(() => {
  3.     const clicked = () => console.log('window clicked')
  4.     window.addEventListener('click', clicked)
  5.  
  6.     // return a clean-up function
  7.     return () => {
  8.       window.removeEventListener('click', clicked)
  9.     }
  10.   }, [])
  11.  
  12.   return <div>
  13.     When you click the window you'll
  14.     find a message logged to the console
  15.   </div>
  16. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top