Flatlist's onViewableItemsChanged presents problems when using with native-base components #20914
Closed
3 tasks done
Labels
Platform: Linux
Building on Linux.
Ran Commands
One of our bots successfully processed a command.
Resolution: Locked
This issue was locked by the bot.
Environment
System:
Binaries:
SDKs:
npmPackages:
npmGlobalPackages:
Description
Flatlist's onViewableItemsChanged prop returns the elements are being viewed by user in viewport. In a basic case, it works great. The problem comes when I try to use the Flatlist inside native-base components. For example, if I use any type of header, the number of elements returned is wrong (because the headers "go down" the list). If I use the component, all the elements are returned as viewed (all of them), thus, the prop is never updated since all the items are "always being viewed" even if they are not in viewport. However, if I replace the Flatlist with Sectionlist (with only one section), this "behavior" doesn't happens; so I think this is a bug in flatlist component.
PD. This occurs both in Android and iOS devices.
Update
This problem also occurs when I place the flatlist inside react-native's Scrollview component. And reading the native-base docs:
So, the issue of returning all the elements (even those are not in viewport) could/would be a matter of Flatlist in Scrollview.
I haven't idea what happens with the headers issue (affecting the number of elements returned).
Reproducible Demo
As the below code shows, it's just a Flatlist component inside native-base component Content and Container. When I run the app, even if there are only 4-5 items of the list in the viewport, onViewableItemsChanged returns in viewableItems array all the elements and never updates.
The text was updated successfully, but these errors were encountered: