Skip to content
Permalink
Browse files

improve VirtualizedList error message (#25973)

Summary:
Motivation: when you receive error like `scrollToIndex out of range: 5 vs -1` it's not immediately clear if I requested 5 or -1. This will make the error a little easier to understand.

## Changelog

not needed
Pull Request resolved: #25973

Test Plan: not needed, tests must pass

Differential Revision: D16708522

Pulled By: osdnk

fbshipit-source-id: 8dfcbd95ff0f42805dbe32cd57969a93aea55add
  • Loading branch information...
vonovak authored and facebook-github-bot committed Aug 12, 2019
1 parent 9b0adb5 commit bef87b648c4bed228f1c5889abe0181a271edf76
Showing with 3 additions and 1 deletion.
  1. +3 −1 Libraries/Lists/VirtualizedList.js
@@ -338,7 +338,9 @@ class VirtualizedList extends React.PureComponent<Props, State> {
const {animated, index, viewOffset, viewPosition} = params;
invariant(
index >= 0 && index < getItemCount(data),
`scrollToIndex out of range: ${index} vs ${getItemCount(data) - 1}`,
`scrollToIndex out of range: requested index ${index} but maximum is ${getItemCount(
data,
) - 1}`,
);
if (!getItemLayout && index > this._highestMeasuredFrameIndex) {
invariant(

0 comments on commit bef87b6

Please sign in to comment.
You can’t perform that action at this time.