Skip to content

Commit

Permalink
fix pointed out
Browse files Browse the repository at this point in the history
  • Loading branch information
sasurau4 committed Apr 15, 2020
1 parent 88b2663 commit f898b30
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
6 changes: 0 additions & 6 deletions Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,6 @@ class VirtualizedList extends React.PureComponent<Props, State> {
data,
)} but minimum is 1`,
);
invariant(
index < getItemCount(data),
`scrollToIndex out of range: requested index ${index} is out of 0 to ${getItemCount(
data,
) - 1}`,
);
if (!getItemLayout && index > this._highestMeasuredFrameIndex) {
invariant(
!!onScrollToIndexFailed,
Expand Down
16 changes: 0 additions & 16 deletions Libraries/Lists/__tests__/VirtualizedList-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,20 +488,4 @@ describe('VirtualizedList', () => {
'scrollToIndex out of range: item length 0 but minimum is 1',
);
});

it('throws if using scrollToIndex when requested index is bigger than or equal to item length', () => {
const component = ReactTestRenderer.create(
<VirtualizedList
data={[{key: 'i1'}, {key: 'i2'}, {key: 'i3'}]}
renderItem={({item}) => <item value={item.key} />}
getItem={(data, index) => data[index]}
getItemCount={data => data.length}
/>,
);
const instance = component.getInstance();

expect(() => instance.scrollToIndex({index: 3})).toThrow(
'scrollToIndex out of range: requested index 3 is out of 0 to 2',
);
});
});

0 comments on commit f898b30

Please sign in to comment.