Skip to content

Commit

Permalink
Cancel throttled fn on unmount
Browse files Browse the repository at this point in the history
  • Loading branch information
KidkArolis committed Aug 19, 2020
1 parent 276ae47 commit e6e8733
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.jsx
Expand Up @@ -35,7 +35,10 @@ export const ReactWindowScroller = ({
}, throttleTime)

window.addEventListener('scroll', handleWindowScroll)
return () => window.removeEventListener('scroll', handleWindowScroll)
return () => {
handleWindowScroll.cancel()
window.removeEventListener('scroll', handleWindowScroll)
}
}, [isGrid])

const onScroll = useCallback(
Expand Down

0 comments on commit e6e8733

Please sign in to comment.