Skip to content

Commit 5dc6e00

Browse files
authored
fix: don't do onScroll when there is no element (#65)
Closes #64
1 parent 856100a commit 5dc6e00

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export function useVirtual({
7171
const element = parentRef.current
7272

7373
const onScroll = () => {
74+
if (!element) return
7475
const scrollOffset = element[scrollKey]
7576
latestRef.current.scrollOffset = scrollOffset
7677
setRange(prevRange => calculateRange(latestRef.current, prevRange))

0 commit comments

Comments
 (0)