2.2.5 • Published 9 months ago

use-window-size-v2 v2.2.5

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

useWindowSize()

Node version NPM total downloads npm bundle size (minified) NPM license

React hook to obtain the current window size in React apps.

useWindowSize() automatically updates width and height values when screen size changes. You can get your application window's width and height like this:

const { width, height } = useWindowSize();

Installation

npm install use-window-size-v2

or

yarn add use-window-size-v2

Usage

This hook returns the current width and height of the window. It is debounced, meaning it will wait delay milliseconds (0ms by default) for the resize events to stop firing before it actually updates its state with the new width and height.

Parameter (optional)

KeyTypeDefaultDescription
delaynumber0The amount of time in milliseconds you want to wait after the latest resize event before updating the size of the window in state.

Return object

TypeDescription
widthnumberThe current width of the window
heightnumberThe current height of the window

Example

Edit react-hook-usewindowsize

import useWindowSize from "use-window-size-v2";

const App = () => {
  const { width, height } = useWindowSize(100); // wait 100ms for the resize events

  return (
    <div>
      <p>Window Width: {width}px</p>
      <p>Window Height: {height}px</p>
    </div>
  );
};

export default App;
2.2.1

11 months ago

2.2.0

11 months ago

2.2.3

11 months ago

2.2.2

11 months ago

2.2.5

9 months ago

2.2.4

10 months ago

2.1.0

11 months ago

2.0.5

12 months ago

2.0.4

1 year ago

2.0.3

1 year ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago