Guest User

Untitled

a guest
Feb 16th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. const ProjectContainer = ({ history, routes }) => {
  2. const onBeforeUnload = (event) => {
  3. if (history.location.pathname !== '/saving-package') {
  4. event.returnValue = 'Changes will not be saved. This action cannot be undone';
  5. }
  6. };
  7. useEffect(() => {
  8. window.addEventListener('beforeunload', onBeforeUnload);
  9. return () => window.removeEventListener('beforeunload', onBeforeUnload);
  10. });
  11. return (
  12. // ...routes
  13. );
  14. };
Add Comment
Please, Sign In to add comment