useIntersectionObserver
Handle the IntersectionObserver (opens in a new tab) API.
Scroll down!
info
the root
option is a function that returns the root element in this hook.
Type Definitions
type IntersectionObserverOptions<T extends HTMLElement> = Omit<IntersectionObserverInit, 'root'> & {
root?: () => Element | Document | null;
ref?: React.RefObject<T> | null;
};
const useIntersectionObserver: <T extends HTMLElement = HTMLDivElement>(args: IntersectionObserverOptions<T> & {
handler: IntersectionObserverCallback;
}) => {
ref: React.RefObject<T>;
observerRef: React.MutableRefObject<IntersectionObserver | undefined>;
};