Skip to content

Commit

Permalink
fix: scrolling to an index that doesn't exist doesn't crash
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerlinsley committed May 14, 2020
1 parent 8c9d958 commit 06f4ac3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ export function useVirtual({

const measurement = measurements[Math.max(0, Math.min(index, size - 1))]

if (!measurement) {
return
}

if (align === 'auto') {
if (measurement.end >= scrollOffsetPlusOuterSize) {
align = 'end'
Expand Down

0 comments on commit 06f4ac3

Please sign in to comment.