useSize
Track the element size easily using useResizeObserver.
Options
- It takes useIntersectionObserver options.
Return Values
Name | Type | Description |
---|---|---|
ref | RefObject | the target element reference. |
width | Number | the target's width. |
height | Number | the target's height. |
Example Usage
tsx
import { useSize } from 'react-pre-hooks';
export default function Example() {
const { ref, width, height } = useSize<HTMLTextAreaElement>();
return (
<main>
<textarea ref={ref} disabled>
Resize me!
</textarea>
</main>
);
}
import { useSize } from 'react-pre-hooks';
export default function Example() {
const { ref, width, height } = useSize<HTMLTextAreaElement>();
return (
<main>
<textarea ref={ref} disabled>
Resize me!
</textarea>
</main>
);
}