useScrollIntersect()function

useScrollIntersect(onEnter?: Nullish<Callback>, onLeave?: Nullish<Callback>): RefObject<T | null>
ParamType
onEnterNullish<Callback>
Called when the element becomes fully visible.
onLeaveNullish<Callback>
Called when the element stops being fully visible.
Return
RefObject<T | null>
A React ref to attach to the element to observe.

Fire callbacks when a referenced element enters or leaves the visible scrolling area.

  • Returns a ref to attach to the element you want to observe — typically the last item in a scrolling list, for infinite-scroll loading.
  • Uses an IntersectionObserver with a full-visibility threshold and disconnects it on unmount or when callbacks change.

Examples

const ref = useScrollIntersect(loadMore); return <div ref={ref} />;