Appearance
useScrollLock
Lock scrolling of the element
Demo
Usage
tsx
import { useScrollLock } from '@reause/core'
import { useRef } from 'react'
const el = useRef<HTMLDivElement>(null)
const [isLocked, setIsLocked] = useScrollLock(el)
setIsLocked(true) // lock
setIsLocked(false) // unlockType Declarations
ts
export type ScrollLockElement = HTMLElement | SVGElement | Window | Document | null | undefined
export type ScrollLockTarget = RefObject<ScrollLockElement>
export type UseScrollLockReturn = [
isLocked: boolean,
setIsLocked: (value: boolean) => void
]
export function useScrollLock(element: ScrollLockTarget, initialState?): UseScrollLockReturn