mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-26 06:47:17 +10:00
Move toggleBasedOnWindowSize to componentDidMount
This commit is contained in:
parent
acb663363f
commit
bf0e933f7c
1 changed files with 2 additions and 14 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue