From 46d1f6ebc78ea8c8d9a26de34e417e361b98958e Mon Sep 17 00:00:00 2001 From: Matt Labrum Date: Tue, 22 Nov 2016 16:03:46 +1030 Subject: [PATCH] Prevent crash when hasLayout has not populated yet --- SmartScrollView.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/SmartScrollView.js b/SmartScrollView.js index fc42423..9d4238b 100644 --- a/SmartScrollView.js +++ b/SmartScrollView.js @@ -72,9 +72,13 @@ class SmartScrollView extends Component { } _findScrollWindowHeight(keyboardHeight){ - const {x, y, width, height} = this._layout - const spaceBelow = screenHeight - y - height; - return height - Math.max(keyboardHeight - spaceBelow, 0); + if(this._layout){ + const {x, y, width, height} = this._layout + const spaceBelow = screenHeight - y - height; + return height - Math.max(keyboardHeight - spaceBelow, 0); + }else{ + return 0 + } } _keyboardWillShow(e) {