mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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: https://github.com/facebook/react-native/pull/25973 Test Plan: not needed, tests must pass Differential Revision: D16708522 Pulled By: osdnk fbshipit-source-id: 8dfcbd95ff0f42805dbe32cd57969a93aea55add
This commit is contained in:
committed by
Facebook Github Bot
parent
9b0adb5ad1
commit
bef87b648c
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user