useScrollLock
Disables scrolling in the document body.
Features
- Removes the scroll bar from the document, while preserving the width of the page.
- Works on any desktop or mobile browser.
Installation
Install the custom hook from your command line.
npm i @raddix/use-scroll-lock
Usage
Once the component using the useScrollLock
hook is mounted, scrolling is disabled
in the document body. When the component is unmounted, the hook returns a cleanup function
that restores the original overflow style.
API
Parameters
The useScrollLock
hook does not accept any parameters.