import ScrollLocker from 'rc-util/lib/Dom/scrollLocker'
import { useCallback, useMemo } from 'react'

export function useBodyScrollLock() {
  const scrollLock = useMemo(() => new ScrollLocker(), [])

  const lock = useCallback(() => scrollLock.lock(), [scrollLock])
  const unlock = useCallback(() => scrollLock.unLock(), [scrollLock])

  return {
    lock,
    unlock
  }
}
