Created
May 4, 2017 17:45
-
-
Save mushfiqweb/1cf970b1c169a534a97d81953c44b03c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyComponent extends React.Component { | |
| // when the component is added to the DOM... | |
| componentDidMount() { | |
| window.addEventListener(‘resize’, this.onResizeHandler); | |
| } | |
| // when the component is removed from the DOM... | |
| componentWillUnmount() { | |
| window.removeEventListener(‘resize’, this.onResizeHandler); | |
| } | |
| onResizeHandler() { | |
| console.log(‘The window has been resized!’); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment