react-native-largelist
react-native-largelist copied to clipboard
Throttling logic in `onScroll` seems to be backwards/incorrect (i.e. it always updates)
While investigating some slow updates (repeatedly seeing old content as I scrolled -- more visible on Android but also happening pretty regularly on iOS) I noticed this line of code which appears to be doing nothing?
https://github.com/bolan9999/react-native-largelist/blob/d93c8985fadafc9f84530bdadc3d63222e1ac10f/src/LargeList.js#L453-L458
this._lastTick
will always be less than now
, so the early return will never be executed AFAICT. Diagnosing it with some console.logs showed this to be the case as well (the early return never executed).
I think this logic should be inverted as follows:
const now = new Date().getTime();
if (now - this._lastTick < 30) {
return;
}
this._lastTick = now;
this._shouldUpdateContent &&
this._groupRefs.forEach((group) =>
idx(() => group.current.contentConversion(offsetY))
);
And possibly it should be using the updateTimeInterval
prop which currently seems to be documented, but completely unused in the code (unless I missed something).