useScrollLock
A custom hook that locks and unlocks scroll.
Installation
npx sse-tool add use-scroll-lock
npm install sse-hooks
Usage
import { useScrollLock } from "./{hooks file}";
// Lock the scroll when the modal is mounted, and unlock it when it's unmounted
useScrollLock();
import { useScrollLock } from "sse-hooks";
// Lock the scroll when the modal is mounted, and unlock it when it's unmounted
useScrollLock();
API
Parameters
| Name | Type | Description |
|---|---|---|
| options | UseScrollLockOptions | Options to configure the hook, by default it will lock the scroll automatically. |
Return Value
Returns UseScrollLockReturn.
- An object containing the lock and unlock functions.