Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const useWindowScroll = (fps = 30): number => {
const [scrollY, setThrottledScroll] = useThrottle(
typeof window === 'undefined' ? 0 : getScrollY,
fps,
true
)
useEffect(() => {
const handleScroll = (): void => setThrottledScroll(getScrollY())
window.addEventListener('scroll', handleScroll)
return (): void => {
window.removeEventListener('scroll', handleScroll)
}
}, emptyArr)
return scrollY
}