@@ -1842,7 +1842,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1842
1842
}
1843
1843
// Mark as high priority if we're close to the end of the last item
1844
1844
// But only if there are items after the last rendered item
1845
- if (last < itemCount - 1 ) {
1845
+ if (last > 0 && last < itemCount - 1 ) {
1846
1846
const distBottom =
1847
1847
this . _getFrameMetricsApprox ( last ) . offset - ( offset + visibleLength ) ;
1848
1848
hiPri =
@@ -1954,7 +1954,11 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1954
1954
// check for invalid frames due to row re-ordering
1955
1955
return frame ;
1956
1956
} else {
1957
- const { getItemLayout } = this . props ;
1957
+ const { data , getItemCount, getItemLayout} = this . props ;
1958
+ invariant (
1959
+ index >= 0 && index < getItemCount ( data ) ,
1960
+ 'Tried to get frame for out of range index ' + index ,
1961
+ ) ;
1958
1962
invariant (
1959
1963
! getItemLayout ,
1960
1964
'Should not have to estimate frames when a measurement metrics function is provided' ,
@@ -1977,7 +1981,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1977
1981
} => {
1978
1982
const { data, getItem, getItemCount, getItemLayout} = this . props ;
1979
1983
invariant (
1980
- getItemCount ( data ) > index ,
1984
+ index >= 0 && index < getItemCount ( data ) ,
1981
1985
'Tried to get frame for out of range index ' + index ,
1982
1986
) ;
1983
1987
const item = getItem ( data , index ) ;
0 commit comments