import { useEffect, useRef } from 'react'; type Props = { onIntersection: () => void; }; const Observer = ({ onIntersection }: Props) => { const observerRef = useRef(null); useEffect(() => { if (!observerRef.current) return; const observer = new IntersectionObserver(([{ isIntersecting }]) => { if (!isIntersecting) return; onIntersection(); }); observer.observe(observerRef.current); return () => { observer.disconnect(); }; }, [onIntersection]); // height monkey patch to make it work with simplebar return ; }; export { Observer };