Move toggleBasedOnWindowSize to componentDidMount

This commit is contained in:
Mikko Koski 2017-05-22 14:24:01 +03:00
parent acb663363f
commit bf0e933f7c

View file

@ -36,11 +36,8 @@ class MobileFrame extends Component {
this.toggleBasedOnWindowSize = this.toggleBasedOnWindowSize.bind(this);
}
componentWillMount() {
this.toggleBasedOnWindowSize();
}
componentDidMount() {
this.toggleBasedOnWindowSize();
window.addEventListener('resize', this.toggleBasedOnWindowSize);
}
@ -54,17 +51,8 @@ class MobileFrame extends Component {
}
toggleBasedOnWindowSize() {
if (typeof window === 'undefined') {
return;
}
const shouldHide = windowWidth() < SHOW_FRAME_BREAKPOINT;
if (shouldHide) {
this.setState({ automaticallyDisabled: true });
} else {
this.setState({ automaticallyDisabled: false });
}
this.setState({ automaticallyDisabled: shouldHide });
}
render() {