-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix VirtualizedList skip measure items - Improve scroll experience #2502
Fix VirtualizedList skip measure items - Improve scroll experience #2502
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit f5b3b8a:
|
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.
Looks good. I wonder if we would we be able to vendor https://github.com/facebook/react-native/tree/main/packages/virtualized-lists package directly instead?
I think we can, I will give a try. To be honest I still learning how the files are organized and exported in RN vs RNW. |
I appreciate all the hard work you've put into identifying and fixes issues in the RN lists. But I would like to stop forking FlatList/VirtualizedList, which is why I've been trying to get those modules packaged out of RN and imported into RNW. Then all patches can be made in once place (the RN repo) which should simplify making fixes and help cross-platform apps with consistency. So I'm unlikely to merge this PR at this time. I understand it's probably also a challenge to get fixes to the lists merged in the RN repo at the moment (sorry about that), but having only one place to get changes reviewed and merged should at least make things better going forward. Let me know if there's anything else I can do |
Thank you for review @necolas but I still need to understand the workflow between RN and RNW.
This PR is only pulling changes from RN and making a change to a RNW patch. |
There's an issue in RN to move Animated, VirtualizedList, and FlatList to packages that get published to npm. facebook/react-native#35263 Once this is complete, RNW will delete the forked modules and import the same npm packages used by RN. All patches for all platforms will need to be made in the packages in the RN monorepo. https://github.com/facebook/react-native/tree/main/packages/virtualized-lists RNW-specific patches for the inverted wheel will be lost. Basically, a fresh start. |
I see that this PR is the result of a bunch of back-and-forth work, and that it's part of a larger Expensify issue that you've been working on for months. Since the progress of publishing those packages in RN is going pretty slowly, I'll merge this PR and make it the last update from the RNW side. Any virtualizedlist features that exist only in RNW should be ported to the RN version in the coming weeks, if you would like to preserve them once the package switch occurs. |
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.
This needs a rebase please
"normalize-css-color": "^1.0.2", | ||
"nullthrows": "^1.1.1", |
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.
I didn't see where this gets used
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.
Here, inside VirtualizedList/index.js
I'm also open to including this patch for VirtualizedList. Let me know if it looks good and is something Expensify wants #2436 Then all the current patches related to scroll wheel will be included at least, and porting anything over to RN might be easier. |
928637f
to
95ad60f
Compare
@necolas this PR also has been rebased! |
Should I move the files to a |
I don't think that's necessary since no more changes will go into this fork. You should let me know about the other patches and issues I mentioned in both your PRs. Which ones are fixed by these PRs, and which ones should also be merged. |
The flow tests are currently failing |
Im on it, looks like there a lot of errors. |
@necolas I have a problem with the modules flow type: Could you help me how to tackle this issue, please? |
c470fe2
to
21a5673
Compare
This commit breaks any RNW app that uses |
People had 6 months to report that change to those libraries and refused to do so. |
@necolas I added these files to fix the modules types problems. Is this ok? |
Hmm, do you know why React Native doesn't have these errors despite not including these module declarations? |
No, It's what I've been trying to figure out. |
This reverts commit bbf9c1d.
@necolas I fixed the typing module from react native perspective. React-Native declares the types in This PR fixes #2432 |
Thank you @necolas, hope I was helpful. |
Thanks! This patch is in release 0.19.2 |
After investigation and feedback I have a new proposal of pull requests to fix the Inverted VirtualizedList in web. Some of the root issues are in react-native-web's end, another issue is fixed updating VirtualizedList from react-native:
Problem 1: VirtualizedList's code relies on that
onLayout
measures items without considering transformations —> Problem Explanation and Solution in this PR.Problem 2: Exists inaccurate measures in onLayout when the setTimeout is executed and any of the targeted nodes (node or relativeNode) for measure are unmounted. —> Problem Explanation and Solution in this PR (same PR that solves problem 1).
Problem 3: The scroll position can be forced to areas where items have not been measured and the list skips measuring items if the user scrolls too fast. —> Problem Explanation and Solution below.
Problem 3
Even if we measure correctly the items of VirtualizedList we still have a problem with the scroll experience if the user scrolls too fast.
The react-native's VirtualizedList updated code fixes this problem but the react-native-web's wheel patch for inverted VirtualizedList opens the possibility for users to force scroll any part of the list and not give enough time for the list to measure items to map their position.
Solution
With all solutions applied and updating VirtualizedList from react-native we have a solid VirtualizedList in web, inverted or non-inverted.
Thank you for reading @necolas, if you have any questions or concerns please let me know how I can help.