useWindowSize
React Element Hooks that tracks window size
Usage
Live Editor
function Demo() { const { width, height } = useWindowSize(); return ( <div> <p> width: {width}, height: {height} </p> </div> ); };
Result
Loading...
API
useWindowSize
Returns
{ readonly width: number; readonly height: number; }
: A object with the following elements:
- width: The current window width.
- height: The current window height.