UNPKG

@mankindui/core

Version:

- a react component library - you can see how @mankindui/core can be used via examples: [usage examples](https://github.com/clarklindev/mankindui-test)

20 lines (19 loc) 591 B
import { useState as o, useRef as f, useEffect as l } from "react"; const i = (r = {}) => { const [c, s] = o(void 0), [n, u] = o(null), e = f(null); return l(() => { e.current && e.current.disconnect(), e.current = new IntersectionObserver(([d]) => s(d), { root: r.root, rootMargin: r.rootMargin, threshold: r.threshold }); const { current: t } = e; return n && t && t.observe(n), () => { t && t.disconnect(); }; }, [n, r.root, r.rootMargin, r.threshold]), [u, c]; }; export { i as useIntersect }; //# sourceMappingURL=useIntersect.js.map