From d576a5bcc0e03dd9c4ccd982f723d6e376e5b680 Mon Sep 17 00:00:00 2001 From: Eli White Date: Mon, 7 Oct 2019 15:30:02 -0700 Subject: [PATCH] Fix bug where ScrollView contentInset top set to undefined wouldn't default to 0 Summary: If you passed ``` contentInset: { bottom: 10 } ``` then it wouldn't go into the if case and it could try to call `setOffset` with `undefined`. `setOffset` requires a number. Changelog: [Fix][ScrollView] ScrollView contentInset top now defaults to 0 in expected situations Reviewed By: JoshuaGross Differential Revision: D17796155 fbshipit-source-id: 951dbbb0de1052f64a6835963e8bbc564990c120 --- Libraries/Components/ScrollView/ScrollView.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 39330fe2f6220a..a99f54eb226aaf 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -739,10 +739,7 @@ class ScrollView extends React.Component { this.props.contentOffset ? this.props.contentOffset.y : 0, ); this._scrollAnimatedValue.setOffset( - /* $FlowFixMe(>=0.98.0 site=react_native_fb) This comment suppresses an - * error found when Flow v0.98 was deployed. To see the error delete this - * comment and run Flow. */ - this.props.contentInset ? this.props.contentInset.top : 0, + this.props.contentInset ? this.props.contentInset.top || 0 : 0, ); this._stickyHeaderRefs = new Map(); this._headerLayoutYs = new Map();