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
This commit is contained in:
Eli White
2019-10-28 17:18:43 +01:00
committed by grabbou
parent 0da6a9bb45
commit 2ddb76a927
@@ -713,10 +713,7 @@ class ScrollView extends React.Component<Props, State> {
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();