import { FC, useEffect, useRef } from 'react' import s from './Sidebar.module.css' import cn from 'classnames' import { disableBodyScroll, enableBodyScroll, clearAllBodyScrollLocks, } from 'body-scroll-lock' interface SidebarProps { children: any onClose: () => void } const Sidebar: FC = ({ children, onClose }) => { const ref = useRef() as React.MutableRefObject useEffect(() => { if (ref.current) { disableBodyScroll(ref.current, { reserveScrollBarGap: true }) } return () => { if (ref && ref.current) { enableBodyScroll(ref.current) } clearAllBodyScrollLocks() } }, []) return (
{children}
) } export default Sidebar