Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ProjectContainer extends Component {
- constructor(props) {
- super(props);
- this.onBeforeUnload = this.onBeforeUnload.bind(this);
- }
- componentDidMount() {
- window.addEventListener('beforeunload', this.onBeforeUnload);
- }
- componentWillUnmount() {
- window.removeEventListener('beforeunload', this.onBeforeUnload);
- }
- onBeforeUnload(event) {
- const { history } = this.props;
- if (history.location.pathname !== '/saving-package') {
- event.returnValue = 'Changes will not be saved. This action cannot be undone';
- }
- }
- render() {
- const { routes } = this.props;
- return (
- // ...routes
- );
- }
- }
Add Comment
Please, Sign In to add comment