Size0.64 kbView sourceuseLockBodyScrollLock and unlock the body scroll without layout shift.Installation npmpnpmyarnbunnpm install @1hook/use-lock-body-scroll Usage import { useLockBodyScroll } from '@1hook/use-lock-body-scroll' The body scroll is automatically unlocked when the hook unmounts. const { lock, unlock, locked } = useLockBodyScroll() Lock on mount: const { lock } = useLockBodyScroll() useEffect(lock, [lock])useLatestRefTransform anything into a ref. The ref is always up to date in effects and DOM events.useMediaRecorderRecord media streams.