Skip to content

Instantly share code, notes, and snippets.

View chan4est's full-sized avatar

Chandler Forrest chan4est

View GitHub Profile
@reecelucas
reecelucas / useScrollBlock.js
Last active July 18, 2024 15:01
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();