useIntersectionObserver

Wraps the IntersectionObserver API to detect when an element enters or leaves the viewport.

Wraps the IntersectionObserver API to detect when an element enters or leaves the viewport. The observer is managed and cleaned up automatically.

Import#

import { useIntersectionObserver } from '@volue/wave-react';

Example#

Scroll down and observe changing visibility boolean as the observed element enters and leaves the viewport.

API Reference#

Arguments#

Prop
Type
Default
target*
Element | RefObject<Element> | null
callback*
IntersectionObserverCallback
options
IntersectionObserverInit
{}

Returns#

void