Skip to content

Commit cad2d9b

Browse files
Be able to scroll to last item in list
Summary: The invariant condition doesn't allow scrolling to the last index Here is a simple reproduction of the problem: https://snack.expo.io/BJ59gzWrZ Surely, if the last item is rendered, we should be able to scroll to it without an invariant failing? Tested locally that this change fixes the issue. Closes #14934 Differential Revision: D5414535 Pulled By: shergin fbshipit-source-id: 38dac4c0e2ae5e1e199a67ca0e98e8f7325e77f4
1 parent e3cfcdf commit cad2d9b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Libraries/Lists/VirtualizedList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
235235
`scrollToIndex out of range: ${index} vs ${getItemCount(data) - 1}`,
236236
);
237237
invariant(
238-
getItemLayout || index < this._highestMeasuredFrameIndex,
238+
getItemLayout || index <= this._highestMeasuredFrameIndex,
239239
'scrollToIndex should be used in conjunction with getItemLayout, ' +
240240
'otherwise there is no way to know the location of an arbitrary index.',
241241
);

0 commit comments

Comments
 (0)