Created
December 15, 2016 05:57
-
-
Save sleexyz/2d1d07c9d37652f86d4bd7c207bf1c68 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
import React, {createClass, createElement, PropTypes} from "react"; | |
const e = createElement; | |
const Fullscreen = (Component) => createClass({ | |
displayName: 'Fullscreen', | |
getInitialState() { | |
return { | |
width: window.innerWidth, | |
height: window.innerHeight | |
}; | |
}, | |
_onResize() { | |
this.setState({ | |
width: window.innerWidth, | |
height: window.innerHeight | |
}); | |
}, | |
componentDidMount() { | |
window.addEventListener('resize', this._onResize, false); | |
}, | |
componentWillUnmount() { | |
window.removeEventListener('resize', this._onResize); | |
}, | |
render() { | |
const {width, height} = this.state; | |
return e(Component, {width, height}); | |
} | |
}); | |
module.exports = Fullscreen; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment