Locks or unlocks body scroll
import { useState } from "react";import { useLockBodyScroll } from "rooks";export default function App() {const [isLocked, setIsLocked] = useState(false);// Lock body scroll when isLocked is trueuseLockBodyScroll(isLocked);return (<div><button onClick={() => setIsLocked(!isLocked)}>{isLocked ? "Unlock scroll" : "Lock scroll"}</button></div>);}
Argument | Type | Description |
---|---|---|
isLocked | boolean | Whether to lock or unlock scroll on the body tag |
Join our discord server! You can click the floating discord icon at the bottom right of the screen and chat with us!