Changelog - 2026-11-04
useIntersection tells whether an element is in view
New FeatureIn one line. useIntersection({ target, rootMargin?, threshold? }) returns the latest IntersectionObserverEntry of the target, or undefined before the first one and where there is no IntersectionObserver. Read entry?.isIntersecting for the boolean.
The example is in useIntersection.
What changed
- The entry, not a boolean. It carries the ratio and the rectangles when you need them. The state changes only when
isIntersectingor the ratio changed, so an unchanged entry does not render. - The target is an element, a ref or
null. It is read after every render, as foruseResizeEffect, so an element held in state or mounted later is followed. A new element,rootMarginorthresholdobserves again fromundefined. - One
threshold, noroot.thresholdis a single number; the viewport is the root, androotMargincovers a scrolling root. - Also in
Ardor.Ardor.useIntersectionjoins the namespace, andardor codemod namespace --hooksknows it. - A new type.
IUseIntersectionOptionsis the options object, andTElementTargetis the type of a target, shared withuseResizeEffect(it wasTResizeTarget, unreleased).
Who is affected
- An app that keeps a hand-written
IntersectionObserverto see whether an element is in view. You can useuseIntersectioninstead and remove the observe, disconnect and server-render guard. - All other apps. No action needed.
See Hooks.