use-lock-body.ts 343 B

12345678910111213
  1. import React from "react";
  2. const useLockBody = () => {
  3. React.useLayoutEffect((): (() => void) => {
  4. const originalStyle: string = window.getComputedStyle(
  5. document.body
  6. ).overflow
  7. document.body.style.overflow = "hidden"
  8. return () => (document.body.style.overflow = originalStyle)
  9. }, [])
  10. }
  11. export default useLockBody