Skip to content

Commit 06f4ac3

Browse files
committed
fix: scrolling to an index that doesn't exist doesn't crash
1 parent 8c9d958 commit 06f4ac3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ export function useVirtual({
189189

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

192+
if (!measurement) {
193+
return
194+
}
195+
192196
if (align === 'auto') {
193197
if (measurement.end >= scrollOffsetPlusOuterSize) {
194198
align = 'end'

0 commit comments

Comments
 (0)