useIntersectionObserver
useIntersectionObserver<
T>(options?):UseIntersectionObserverReturn<T>
Defined in: src/hooks/useIntersectionObserver/useIntersectionObserver.ts:28
Observe whether an element intersects a root (defaults to the viewport).
Returns a ref callback to attach to the observed element plus the latest
IntersectionObserverEntry. SSR-safe: returns a no-op ref and null
entry when IntersectionObserver is unavailable.
Type Parameters
Section titled “Type Parameters”T extends Element = Element
Parameters
Section titled “Parameters”options?
Section titled “options?”UseIntersectionObserverOptions = {}
Returns
Section titled “Returns”UseIntersectionObserverReturn<T>
Example
Section titled “Example”const { ref, isIntersecting } = useIntersectionObserver<HTMLDivElement>({ rootMargin: '200px',});useEffect(() => { if (isIntersecting) loadMore();}, [isIntersecting]);return <div ref={ref} />;