UNPKG

react-window-mixins

Version:

React mixins for working with browser window events.

22 lines (19 loc) 513 B
/*global window */ module.exports = { componentDidMount: function() { if (this.onUnload) { window.addEventListener("unload", this.onUnload); } if (this.onBeforeUnload) { window.addEventListener("beforeunload", this.onBeforeUnload); } }, componentWillUnmount: function() { if (this.onUnload) { window.removeEventListener("unload", this.onUnload); } if (this.onBeforeUnload) { window.removeEventListener("beforeunload", this.onBeforeUnload); } } };