Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- constructor(props) {
- super(props);
- this.state = { width: 0, height: 0 };
- this.updateWindowDimensions = this.updateWindowDimensions.bind(this);
- }
- componentDidMount() {
- this.updateWindowDimensions();
- window.addEventListener('resize', this.updateWindowDimensions);
- }
- componentWillUnmount() {
- window.removeEventListener('resize', this.updateWindowDimensions);
- }
- updateWindowDimensions() {
- this.setState({ width: window.innerWidth, height: window.innerHeight });
- }
Add Comment
Please, Sign In to add comment