"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "useEndReached", {
    enumerable: true,
    get: function() {
        return useEndReached;
    }
});
const _react = require("react");
function useEndReached(sentinelRef, onEndReached) {
    const observer = (0, _react.useRef)();
    const cb = (0, _react.useRef)(onEndReached);
    cb.current = onEndReached;
    (0, _react.useEffect)(()=>{
        const options = {
            root: null,
            rootMargin: "0px",
            threshold: 0
        };
        const handleObserver = (entries)=>{
            entries.forEach((entry)=>{
                if (entry.isIntersecting) {
                    cb.current?.();
                }
            });
        };
        observer.current = new IntersectionObserver(handleObserver, options);
        return ()=>{
            observer.current?.disconnect();
        };
    }, []);
    (0, _react.useEffect)(()=>{
        observer.current?.observe(sentinelRef.current);
    }, []);
}

//# sourceMappingURL=useEndReached.js.map