Skip to content

Commit

Permalink
Be able to scroll to last item in list
Browse files Browse the repository at this point in the history
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
  • Loading branch information
maartenschumacher authored and facebook-github-bot committed Jul 13, 2017
1 parent e3cfcdf commit cad2d9b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
`scrollToIndex out of range: ${index} vs ${getItemCount(data) - 1}`,
);
invariant(
getItemLayout || index < this._highestMeasuredFrameIndex,
getItemLayout || index <= this._highestMeasuredFrameIndex,
'scrollToIndex should be used in conjunction with getItemLayout, ' +
'otherwise there is no way to know the location of an arbitrary index.',
);
Expand Down

0 comments on commit cad2d9b

Please sign in to comment.