Skip to content

Instantly share code, notes, and snippets.

@reecelucas
reecelucas / useScrollBlock.js
Last active November 13, 2024 08:19
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();