Detect when an element resizes. Returns the width and height of the element passed into the hook parameter.

Usage

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

Example

import { useSize } from 'vev';
import { useRef } from 'react';

export default function(){
const elementReference = useRef<Element>(null);
const { width, height } = useSize(elementReference);
return (
<div ref={elementReference}>
{width}x{height}
</div>
);
}

Did this answer your question?