|
Download react-use/docs/useSize.md from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 649 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-use/docs/useSize.md
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/react-use/docs/useSize.md
-
curl -L -o useSize.md https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-use/docs/useSize.md
649 Bytes
useSize
React sensor hook that tracks size of an HTML element.
Usage
import {useSize} from 'react-use';
const Demo = () => {
const [sized, {width, height}] = useSize(
({width}) => <div style={{background: 'red'}}>Size me up! ({width}px)</div>,
{ width: 100, height: 100 }
);
return (
<div>
{sized}
<div>width: {width}</div>
<div>height: {height}</div>
</div>
);
};
Reference
useSize(element, initialSize);
element— sized element.initialSize— initial size containing awidthandheightkey.