From bf0e933f7cdecd50ef78bc1934dacfc001325a9c Mon Sep 17 00:00:00 2001 From: Mikko Koski Date: Mon, 22 May 2017 14:24:01 +0300 Subject: [PATCH] Move toggleBasedOnWindowSize to componentDidMount --- src/components/MobileFrame/MobileFrame.js | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/components/MobileFrame/MobileFrame.js b/src/components/MobileFrame/MobileFrame.js index 386a0bf2..17170f72 100644 --- a/src/components/MobileFrame/MobileFrame.js +++ b/src/components/MobileFrame/MobileFrame.js @@ -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() {