1.0.0 • Published 3 years ago

@utilityjs/use-scroll-guard v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

A React hook that disables/enables the page scroll.

license npm latest package npm downloads types

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;