Skip to content

Commit

Permalink
fix: don't do onScroll when there is no element (#65)
Browse files Browse the repository at this point in the history
Closes #64
  • Loading branch information
kentcdodds authored Sep 14, 2020
1 parent 856100a commit 5dc6e00
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export function useVirtual({
const element = parentRef.current

const onScroll = () => {
if (!element) return
const scrollOffset = element[scrollKey]
latestRef.current.scrollOffset = scrollOffset
setRange(prevRange => calculateRange(latestRef.current, prevRange))
Expand Down

0 comments on commit 5dc6e00

Please sign in to comment.