mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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.  So I suggest to update `_scrollAnimatedValue` offset when ScrollView contentInset is updated. Pull Request resolved: https://github.com/facebook/react-native/pull/19481 Differential Revision: D14223304 Pulled By: cpojer fbshipit-source-id: 4191cfcf6414adf3a0abd156517d5f9778565671
This commit is contained in:
committed by
Mike Grabowski
parent
57dc37ec5b
commit
e0d1b3ab84
@@ -662,6 +662,18 @@ class ScrollView extends React.Component<Props, State> {
|
||||
this._headerLayoutYs = new Map();
|
||||
}
|
||||
|
||||
UNSAFE_componentWillReceiveProps(nextProps: Props) {
|
||||
const currentContentInsetTop = this.props.contentInset
|
||||
? this.props.contentInset.top
|
||||
: 0;
|
||||
const nextContentInsetTop = nextProps.contentInset
|
||||
? nextProps.contentInset.top
|
||||
: 0;
|
||||
if (currentContentInsetTop !== nextContentInsetTop) {
|
||||
this._scrollAnimatedValue.setOffset(nextContentInsetTop || 0);
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this._updateAnimatedNodeAttachment();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user