react-native-draggable-flatlist
react-native-draggable-flatlist copied to clipboard
getItemLayout performance optimization
This library is the only one that actually just works! Huge thanks @computerjazz
But when list become large (even dozens of items on slow Android device) scrolling become unresponsive, compared to just barebone Flatlist.
I checked source code and noticed that you use measureLayout
method for each cell. Flatlist actually have a great solution to speed up cell measuring called getItemLayout
.
So why not use getItemLayout
prop when it specified to speed up measure process?
It has length
(height) and offset
values, probably those values must be enough?
I tested locally and it works great! No more Excessive number of pending callbacks: measureLayout
and scrolling now fluid.
I only not sure how to properly (in performant manner) get ancestor offset, so I used hardcoded value instead.
Will be great if you have any time to check this! Thanks in advance
getItemLayout
only works if you know each item's height ahead of time and won't work for dynamic content.
Agree we could leverage it for cases where this is known ahead of time but wouldn't work for everyone.
Absolutely. This library should work for both use-cases (dynamic and fixed sizes).
Cells with fixed height are common on mobile. Probably you meet them way often than dynamic. So for my opinion this change will benefit many end users.
Also getItemLayout
is already known property by React Native developers, so no further explanation is needed about how to use it
Agreed with @exentrich.
100% Agree with @exentrich
Sounds good to me, you're welcome to submit a PR!
@exentrich did you end up forking the lib, or try something else?