-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
33 lines (27 loc) · 812 Bytes
/
main.js
File metadata and controls
33 lines (27 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class AppDecider extends React.Component {
constructor(props) {
super(props);
this.state = { width : 0, height : 0, isMobile : false};
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,
isMobile: window.innerWidth < window.innerHeight
});
}
render(){
return (
this.state.isMobile ? <MobileApp /> : <DesktopApp />
)
}
}
ReactDOM.render(<AppDecider />, document.getElementById('root'));