usePreventScroll
Prevents scrolling on the document body on mount, and restores it on unmount. Also ensures that content does not shift due to the scrollbars disappearing.
| install | yarn add @react-aria/overlays |
|---|---|
| version | 3.6.3 |
| usage | import {usePreventScroll} from '@react-aria/overlays' |
API#
usePreventScroll(
(options: PreventScrollOptions
)): anyExample#
See useDialog for an example of using usePreventScroll to prevent
scrolling on the document body on dialog mount.