Skip to content

Commit b8a64f0

Browse files
committed
office-shared-comments-ui aeb76bb4
1 parent e57c818 commit b8a64f0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Libraries/Lists/VirtualizedList.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,7 +1842,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
18421842
}
18431843
// Mark as high priority if we're close to the end of the last item
18441844
// But only if there are items after the last rendered item
1845-
if (last < itemCount - 1) {
1845+
if (last > 0 && last < itemCount - 1) {
18461846
const distBottom =
18471847
this._getFrameMetricsApprox(last).offset - (offset + visibleLength);
18481848
hiPri =
@@ -1954,7 +1954,11 @@ class VirtualizedList extends React.PureComponent<Props, State> {
19541954
// check for invalid frames due to row re-ordering
19551955
return frame;
19561956
} 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+
);
19581962
invariant(
19591963
!getItemLayout,
19601964
'Should not have to estimate frames when a measurement metrics function is provided',
@@ -1977,7 +1981,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
19771981
} => {
19781982
const {data, getItem, getItemCount, getItemLayout} = this.props;
19791983
invariant(
1980-
getItemCount(data) > index,
1984+
index >= 0 && index < getItemCount(data),
19811985
'Tried to get frame for out of range index ' + index,
19821986
);
19831987
const item = getItem(data, index);

0 commit comments

Comments
 (0)