Skip to content

Fix Animated Value initialized with undefined in ScrollView #28349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Libraries/Components/ScrollView/ScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,11 +716,9 @@ class ScrollView extends React.Component<Props, State> {
UNSAFE_componentWillMount() {
this._scrollResponder.UNSAFE_componentWillMount();
this._scrollAnimatedValue = new AnimatedImplementation.Value(
this.props.contentOffset ? this.props.contentOffset.y : 0,
);
this._scrollAnimatedValue.setOffset(
this.props.contentInset ? this.props.contentInset.top || 0 : 0,
this.props.contentOffset?.y ?? 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there is no FlowFixMe here, my guess is there is a FlowFixMe somewhere in its usage and I'd rather we fix it there than mask the error by providing a default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The crash was happening for me in a third party library that did not use flow / typescript. I'm also fine keeping the behavior as is and fixing the library only, the goal of this is mostly to keep the same runtime behavior as before.

);
this._scrollAnimatedValue.setOffset(this.props.contentInset?.top ?? 0);
this._stickyHeaderRefs = new Map();
this._headerLayoutYs = new Map();
}
Expand Down