@arolariu/components
Version:
🎨 70+ beautiful, accessible React components built on Base UI. TypeScript-first, CSS Modules styling, tree-shakeable, SSR-ready. Perfect for modern web apps, design systems & rapid prototyping. Zero config, maximum flexibility! ⚡
32 lines (31 loc) • 977 B
JavaScript
"use client";
import * as __rspack_external_react from "react";
function useIntersectionObserver(ref, options) {
const [entry, setEntry] = __rspack_external_react.useState(null);
const threshold = options?.threshold;
const root = options?.root;
const rootMargin = options?.rootMargin;
__rspack_external_react.useEffect(()=>{
const element = ref.current;
if (void 0 === globalThis.IntersectionObserver || !element) return;
const observer = new globalThis.IntersectionObserver(([observerEntry])=>{
if (observerEntry) setEntry(observerEntry);
}, {
threshold,
root,
rootMargin
});
observer.observe(element);
return ()=>{
observer.disconnect();
};
}, [
ref,
threshold,
root,
rootMargin
]);
return entry;
}
export { useIntersectionObserver };
//# sourceMappingURL=useIntersectionObserver.js.map