Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions packages/virtualized-lists/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,6 @@ type State = {
pendingScrollUpdateCount: number,
};

function findLastWhere<T>(
arr: $ReadOnlyArray<T>,
predicate: (element: T) => boolean,
): T | null {
for (let i = arr.length - 1; i >= 0; i--) {
if (predicate(arr[i])) {
return arr[i];
}
}

return null;
}

function getScrollingThreshold(threshold: number, visibleLength: number) {
return (threshold * visibleLength) / 2;
}
Expand Down Expand Up @@ -987,7 +974,8 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
const spacerKey = this._getSpacerKey(!horizontal);

const renderRegions = this.state.renderMask.enumerateRegions();
const lastSpacer = findLastWhere(renderRegions, r => r.isSpacer);
const lastRegion = renderRegions[renderRegions.length - 1];
const lastSpacer = lastRegion?.isSpacer ? lastRegion : null;

for (const section of renderRegions) {
if (section.isSpacer) {
Expand Down