Skip to content

Commit

Permalink
Fix bug where ScrollView contentInset top set to undefined wouldn't d…
Browse files Browse the repository at this point in the history
…efault 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
  • Loading branch information
elicwhite authored and facebook-github-bot committed Oct 7, 2019
1 parent 15be144 commit d576a5b
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions Libraries/Components/ScrollView/ScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,10 +739,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();
Expand Down

0 comments on commit d576a5b

Please sign in to comment.