@utilityjs/use-scroll-guard
v1.0.0
Published
A React hook that disables/enables the page scroll.
Downloads
32
Maintainers
Readme
A React hook that disables/enables the page scroll.
npm i @utilityjs/use-scroll-guard | yarn add @utilityjs/use-scroll-guard
Usage
const App = () => {
const { enablePageScroll, disablePageScroll } = useScrollGuard();
return (
<div className="app">
<button onClick={() => void enablePageScroll()}>Enable</button>
<button onClick={() => void disablePageScroll()}>Disable</button>
</div>
);
};
API
useScrollGuard()
declare type UseScrollGuard = () => {
enablePageScroll: () => void;
disablePageScroll: () => void;
};
declare const useScrollGuard: UseScrollGuard;