usebrowserwindowsize
v0.1.2
Published
Simple React hook providing window width and height updates are triggered on window resize event.
Downloads
8
Maintainers
Readme
📐 useBrowserWindowSize
React hook for getting width and height of browser window. Will update on window resize event.
🚀 Getting Started
Usage: useBrowserWindowSize react hook
Add to your project npm i usebrowserwindowsize
or using yarn yarn add usebrowserwindowsize
.
Simply import the hook to your component.
import useBrowserWindowSize from 'usebrowserwindowsize';
Then you can destruct either width or height (or both) from the hooks return value (Array). Please note that it will be [0, 0] initially.
const [ windowWidth, windowHeight ] = useBrowserWindowSize();
All properties typed as integers.