mirror of
https://github.com/streamich/react-use.git
synced 2025-12-08 18:02:14 +00:00
381 B
381 B
useSize
React sensor hook that tracks size of some HTML element.
Usage
import {useSize} from 'react-use';
const Demo = () => {
const [sized, {width, height}] = useSize(
<div style={{border: '1px solid red'}}>Size me up!</div>
);
return (
<div>
{sized}
<div>width: {width}</div>
<div>height: {height}</div>
</div>
);
};