-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Update _scrollAnimatedValue offset of ScrollViews. #19481
Conversation
# Conflicts: # React/Views/RCTScrollView.m
# Conflicts: # Libraries/Components/ScrollView/ScrollView.js
This comment has been minimized.
This comment has been minimized.
I added Release Notes. |
@miyabi I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project. |
…react-native into fix-scroll-animated-value-offset
@miyabi I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project. |
@shergin Could you review this PR? |
Thanks for this PR! Sorry that it took so long to get back to you. In order to merge it, please fix the flow error. Also, can you make it so the method is only invoked if the inset changed between props? Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code analysis results:
eslint
found some issues. Runyarn lint --fix
to automatically fix problems.
const currentContentInset = this.props.contentInset || {}; | ||
const nextContentInset = nextProps.contentInset || {}; | ||
if (currentContentInset.top !== nextContentInset.top) { | ||
this._scrollAnimatedValue.setOffset( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prettier/prettier: Replace ⏎········nextContentInset.top·||·0,⏎······
with nextContentInset.top·||·0
@cpojer Thank you for reviewing. I fixed error and updated my code. |
Thank you! I don't think it's a good idea to create up to two empty objects every time the props change. Could you change your code to be a bit more verbose but doesn't create empty objects? |
@cpojer I improved my code. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This pull request was successfully merged by @miyabi in 58c9567. When will my fix make it into a release? | Upcoming Releases |
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
Motivation
_scrollAnimatedValue
offset of ScrollView is set once inUNSAFE_componentWillMount
but it is never updated.It causes unexpected render result.
So I suggest to update
_scrollAnimatedValue
offset when ScrollView contentInset is updated.Test Plan
Here is a demo and an example code:
Release Notes
[IOS][BUGFIX][ScrollView] Fix that _scrollAnimatedValue offset is not updated even contentInset is updated.