Skip to content

Instantly share code, notes, and snippets.

View celian-rib's full-sized avatar
🛰️
probably parsing something with no garbage collector

Célian Riboulet celian-rib

🛰️
probably parsing something with no garbage collector
View GitHub Profile
@celian-rib
celian-rib / useScrollBlock.ts
Last active May 24, 2024 08:54 — forked from reecelucas/useScrollBlock.js
React hook to enable/disable page scroll (Typescript version)
import { useRef } from 'react';
const safeDocument: Document = document;
/**
* Usage:
* const [blockScroll, allowScroll] = useScrollBlock();
*/
export const useScrollBlock = (): [() => void, () => void] => {
const scrollBlocked = useRef(false);