import React, { FC, PropsWithChildren, useContext, useEffect, useRef, } from 'react'; import cn from 'classnames'; import { CustomScroll } from 'vevet'; import { prefixedClasNames } from '../../../utils/prefixedClassNames'; import { PageScrollContext } from '../context'; /** * Container for custom scrolling. * Wrap your page with this component to enable custom scrolling. */ export const CustomContainer: FC = ({ children }) => { const ref = useRef(null); const { selector, setCustomContainer } = useContext(PageScrollContext); const isCustom = selector instanceof CustomScroll; useEffect(() => { setCustomContainer?.(ref.current); return () => setCustomContainer?.(null); }, [setCustomContainer]); return (
{children}
); };