|
Download react-use/docs/useWindowSize.md from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 664 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-use/docs/useWindowSize.md
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/react-use/docs/useWindowSize.md
-
curl -L -o useWindowSize.md https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-use/docs/useWindowSize.md
664 Bytes
| # `useWindowSize` | |
| React sensor hook that tracks dimensions of the browser window. | |
| ## Usage | |
| ```jsx | |
| import {useWindowSize} from 'react-use'; | |
| const Demo = () => { | |
| const {width, height} = useWindowSize(); | |
| return ( | |
| <div> | |
| <div>width: {width}</div> | |
| <div>height: {height}</div> | |
| </div> | |
| ); | |
| }; | |
| ``` | |
| ## Reference | |
| ```js | |
| useWindowSize(options); | |
| ``` | |
| - `initialWidth` — Initial width value for non-browser environments. | |
| - `initialHeight` — Initial height value for non-browser environments. | |
| - `onChange` — Callback function triggered when the window size changes. | |
| ## Related hooks | |
| - [useSize](./useSize.md) | |
| - [useMeasure](./useMeasure.md) |