hook-usewindowwidth
v0.0.3
Published
A react hook to get access to the current width of the browser window.
Downloads
1
Readme
This react hook exposes the current window width to our react component. It also considers window resizing.
Installation
npm install hook-usewindowwidth
Example
import React from 'react';
import ReactDOM from 'react-dom';
import useWindowWidth from 'hook-usewindowwidth';
const DisplayWindowWidth = () => {
const windowWidth = useWindowWidth();
return (
<p>The current window width is {windowWidth}</p>
)
}
ReactDOM.render(<DisplayWindowWidth />, rootElement);
Requirements
This hook requires React 16.8.0
or higher. As a result React 16.8.0
is also a peer dependency of this package.