one-hook
Size
0.64 kb
View source

useLockBodyScroll

Lock and unlock the body scroll without layout shift.

Installation

npm install @1hook/use-lock-body-scroll

Usage

import {  } from '@1hook/use-lock-body-scroll'

The body scroll is automatically unlocked when the hook unmounts.

const { , ,  } = ()

Lock on mount:

const {  } = ()

(, [])

On this page