import { useCallback, useEffect, useState } from "react";
const useIntersectionObserver = (observerOptions, handleIntersection) => {
  const [element, setElement] = useState(null);
  const handleElement = useCallback((node) => {
    setElement(node);
  }, []);
  useEffect(() => {
    if (!element)
      return;
    const observer = new IntersectionObserver(handleIntersection, observerOptions);
    observer.observe(element);
    return () => observer && observer.disconnect && observer.disconnect();
  }, [handleIntersection, observerOptions, element]);
  return handleElement;
};
var stdin_default = useIntersectionObserver;
export {
  stdin_default as default
};
