useResizeObserver
Custom hook that observes the size of an element using the [
ResizeObserver API](https://developer.Installation
npx sse-tool add use-resize-observer
npm install sse-hooks
Usage
import { useResizeObserver } from "./{hooks file}";
const myRef = useRef(null);
const { width = 0, height = 0 } = useResizeObserver({
ref: myRef,
box: "content-box",
});
<div ref={myRef}>Hello, world!</div>;
import { useResizeObserver } from "sse-hooks";
const myRef = useRef(null);
const { width = 0, height = 0 } = useResizeObserver({
ref: myRef,
box: "content-box",
});
<div ref={myRef}>Hello, world!</div>;
API
Parameters
| Name | Type | Description |
|---|---|---|
| options | UseResizeObserverOptions | The options for the ResizeObserver. |
Return Value
Returns Size.
- The size of the observed element.