Skip to content

Instantly share code, notes, and snippets.

View acharyarupak391's full-sized avatar
💭
writing buggy code and wondering why it isn't working

Rupak acharyarupak391

💭
writing buggy code and wondering why it isn't working
View GitHub Profile

The hook

useScrollPosition.js:

import { useRef, useLayoutEffect } from 'react'

const isBrowser = typeof window !== `undefined`

function getScrollPosition({ element, useWindow }) {