SHARE
TWEET

Untitled

a guest Feb 16th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class ProjectContainer extends Component {
  2.     constructor(props) {
  3.         super(props);
  4.         this.onBeforeUnload = this.onBeforeUnload.bind(this);
  5.     }
  6.  
  7.     componentDidMount() {
  8.         window.addEventListener('beforeunload', this.onBeforeUnload);
  9.     }
  10.  
  11.     componentWillUnmount() {
  12.         window.removeEventListener('beforeunload', this.onBeforeUnload);
  13.     }
  14.  
  15.     onBeforeUnload(event) {
  16.         const { history } = this.props;
  17.         if (history.location.pathname !== '/saving-package') {
  18.             event.returnValue = 'Changes will not be saved. This action cannot be undone';
  19.         }
  20.     }
  21.  
  22.     render() {
  23.         const { routes } = this.props;
  24.         return (
  25.             // ...routes
  26.         );
  27.     }
  28. }
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