Vev Help Center
Search…
useSize hook
Detect when an element resizes. Returns width and height of the element passed into the hook parameter.

Usage

1
const useSizeHook: {width: number, height: number} = useSize(React.RefObject);
Copied!

Example

1
import { useSize } from 'vev';
2
import { useRef } from 'react';
3
​
4
export default function(){
5
const elementReference = useRef<Element>(null);
6
const { width, height } = useSize(elementReference);
7
return (
8
<div ref={elementReference}>
9
{width}x{height}
10
</div>
11
);
12
}
Copied!
Copy link
Contents
Usage
Example