Skip to content

A react hook to get access to the current width of the browser window.

License

Notifications You must be signed in to change notification settings

blue-tomato/useWindowWidth

Repository files navigation

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.

About

A react hook to get access to the current width of the browser window.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published