Skip to content

useResizeObserver ​

Category
Browser

Hook that gives you resize observer state

typescript
import { useResizeObserver } from '@siberiacancode/reactuse';

Usage ​

typescript
const { ref, entries } = useResizeObserver();

Demo ​

Api ​

Parameters

NameTypeDefaultNote
options.enabled?booleantrueThe IntersectionObserver options
options.box?boolean-The IntersectionObserver options
options.onChange?(entries: ResizeObserverEntry[], observer: ResizeObserver) => void-The callback to execute when resize is detected

Parameters

NameTypeDefaultNote
targetTarget-The target element to observe
options.enabled?booleantrueThe IntersectionObserver options
options.box?boolean-The IntersectionObserver options
options.onChange?(entries: ResizeObserverEntry[], observer: ResizeObserver) => void-The callback to execute when resize is detected

Contributors ​

Source • Demo