diff --git a/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js b/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js index b54c238d1e8646..50b867e6cbfaa1 100644 --- a/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js +++ b/Libraries/Lists/VirtualizedList_EXPERIMENTAL.js @@ -608,7 +608,9 @@ class VirtualizedList extends StateSafePureComponent { // Wait until the scroll view metrics have been set up. And until then, // we will trust the initialNumToRender suggestion if (visibleLength <= 0 || contentLength <= 0) { - return cellsAroundViewport; + return cellsAroundViewport.last >= getItemCount(data) + ? VirtualizedList._constrainToItemCount(cellsAroundViewport, props) + : cellsAroundViewport; } let newCellsAroundViewport: {first: number, last: number}; @@ -654,6 +656,10 @@ class VirtualizedList extends StateSafePureComponent { this.__getFrameMetricsApprox, this._scrollMetrics, ); + invariant( + newCellsAroundViewport.last < getItemCount(data), + 'computeWindowedRenderLimits() should return range in-bounds', + ); } if (this._nestedChildLists.size > 0) {