Skip to content

Commit bef87b6

Browse files
vonovakfacebook-github-bot
authored andcommitted
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
1 parent 9b0adb5 commit bef87b6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Libraries/Lists/VirtualizedList.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,9 @@ class VirtualizedList extends React.PureComponent<Props, State> {
338338
const {animated, index, viewOffset, viewPosition} = params;
339339
invariant(
340340
index >= 0 && index < getItemCount(data),
341-
`scrollToIndex out of range: ${index} vs ${getItemCount(data) - 1}`,
341+
`scrollToIndex out of range: requested index ${index} but maximum is ${getItemCount(
342+
data,
343+
) - 1}`,
342344
);
343345
if (!getItemLayout && index > this._highestMeasuredFrameIndex) {
344346
invariant(

0 commit comments

Comments
 (0)