useLockBodyScroll()
The
useLockBodyScroll() hook prevents the user from scrolling the main page body. This is essential when displaying modals, sidebars, or full-screen menus to prevent the background content from moving while the user interacts with the overlay.Import
typescript
Usage
Click the button to open a modal and lock the main page scroll.
Component.tsx
API
Arguments
This hook does not accept any arguments.
Returns
This hook returns
void. It performs its side effect directly on the DOM.