mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Attempt fix for cellsAroundViewport reaching out of bounds
Summary: VirtualizedList would more gracefully handle out of range cells than VirtualizedList_EXPERIMENTAL, which treats it as an invariant violation. This attempts to fix an issue where recalculation of cells around viewport can include out of range cells. Reviewed By: rshest Differential Revision: D39244112 fbshipit-source-id: 20fe6ea552035061d9d00720fcab77b29a785771
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a50e6fb341
commit
7aa203beda
@@ -128,7 +128,7 @@ export function computeWindowedRenderLimits(
|
||||
} {
|
||||
const itemCount = props.getItemCount(props.data);
|
||||
if (itemCount === 0) {
|
||||
return prev;
|
||||
return {first: 0, last: -1};
|
||||
}
|
||||
const {offset, velocity, visibleLength, zoomScale = 1} = scrollMetrics;
|
||||
|
||||
|
||||
@@ -641,7 +641,9 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
|
||||
!this._scrollMetrics.offset &&
|
||||
Math.abs(distanceFromEnd) >= Number.EPSILON
|
||||
) {
|
||||
return cellsAroundViewport;
|
||||
return cellsAroundViewport.last >= getItemCount(data)
|
||||
? VirtualizedList._constrainToItemCount(cellsAroundViewport, props)
|
||||
: cellsAroundViewport;
|
||||
}
|
||||
|
||||
newCellsAroundViewport = computeWindowedRenderLimits(
|
||||
|
||||
Reference in New Issue
Block a user