daily pastebin goal
17%
SHARE
TWEET

Untitled

a guest Feb 16th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const useEventListener = () => {
  2.     const onBeforeUnload = (event) => {
  3.         event.returnValue = 'Changes will not be saved. This action cannot be undone'; // eslint-disable-line no-param-reassign
  4.     };
  5.     useEffect(() => {
  6.         window.addEventListener('beforeunload', onBeforeUnload);
  7.         return () => window.removeEventListener('beforeunload', onBeforeUnload);
  8.     });
  9. };
  10.  
  11. const ProjectContainer = () => {
  12.     // I just have to called my hook
  13.   useEventListener();
  14.     return (
  15.             <div>Hi</div>      
  16.     );
  17. };
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