Skip to content

Commit e0d1b3a

Browse files
miyabigrabbou
authored andcommitted
Update _scrollAnimatedValue offset of ScrollViews. (#19481)
Summary: `_scrollAnimatedValue` offset of ScrollView is set once in `UNSAFE_componentWillMount` but it is never updated. It causes unexpected render result. ![rn-scrollview-fix1](https://user-images.githubusercontent.com/143255/40640292-61843eca-6350-11e8-9412-f5383ea65ea0.gif) So I suggest to update `_scrollAnimatedValue` offset when ScrollView contentInset is updated. Pull Request resolved: #19481 Differential Revision: D14223304 Pulled By: cpojer fbshipit-source-id: 4191cfcf6414adf3a0abd156517d5f9778565671
1 parent 57dc37e commit e0d1b3a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Libraries/Components/ScrollView/ScrollView.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,18 @@ class ScrollView extends React.Component<Props, State> {
662662
this._headerLayoutYs = new Map();
663663
}
664664

665+
UNSAFE_componentWillReceiveProps(nextProps: Props) {
666+
const currentContentInsetTop = this.props.contentInset
667+
? this.props.contentInset.top
668+
: 0;
669+
const nextContentInsetTop = nextProps.contentInset
670+
? nextProps.contentInset.top
671+
: 0;
672+
if (currentContentInsetTop !== nextContentInsetTop) {
673+
this._scrollAnimatedValue.setOffset(nextContentInsetTop || 0);
674+
}
675+
}
676+
665677
componentDidMount() {
666678
this._updateAnimatedNodeAttachment();
667679
}

0 commit comments

Comments
 (0)