Skip to main content
useSize Hook
Diego Muralles avatar
Written by Diego Muralles
Updated over a week ago

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


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


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}>

Did this answer your question?