@wbe/use-window-size

Returned dynamic window size

Usage no npm install needed!

<script type="module">
  import wbeUseWindowSize from 'https://cdn.skypack.dev/@wbe/use-window-size';
</script>

README

@wbe/use-window-size

This React hook allow to get dynamically window dimensions.

Installation

$ npm install -s @wbe/use-window-size

How to use

import { useWindowSize } from "@wbe/use-window-size";

const App = () => {
  // get window size
  const { width, height } = useWindowSize();

  // Resize your browser and check width & height change.
  return (
    <ul>
      <li>window width: {width}</li>
      <li>window height: {height}</li>
    </ul>
  );
};

Returned

The hook return object who contains window dimensions:

{
  "width": number,
  "height": number
}