Skip to content

Instantly share code, notes, and snippets.

@skipsleep
skipsleep / useScrollBlock.js
Created November 11, 2022 04:25 — forked from reecelucas/useScrollBlock.js
React hook to enable/disable page scroll
import { useRef } from 'react';
const safeDocument = typeof document !== 'undefined' ? document : {};
/**
* Usage:
* const [blockScroll, allowScroll] = useScrollBlock();
*/
export default () => {
const scrollBlocked = useRef();