1.0.5 • Published 3 years ago

@react-typed-hooks/use-window-size v1.0.5

Weekly downloads
198
License
MIT
Repository
github
Last release
3 years ago

useWindowSize

React hook that returns the window size. Updates on window resize and orientation change.

version

Installation

npm install @react-typed-hooks/use-window-size

Usage

import { useWindowSize } from "@react-typed-hooks/use-window-size";

const Demo = () => {
  const size = useWindowSize();

  return size ? (
    <pre>JSON.stringify(size, null, 4)</pre>
  ) : (
    <span>Size is null in a node like environment</span>
  );
};

API

Types

interface Size {
  height: number;
  width: number;
}

interface UseWindowSizeOptions {
  wait?: number;
}
function useWindowSize(options?: UseWindowSizeOptions): Size | null;

Options

wait

The amount of time to delay updating Size after the orientation changes.

The amount of time to throttle between updating Size when the window is resized.

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

4 years ago

1.0.0-alpha.3

4 years ago

1.0.0-alpha.2

4 years ago

1.0.0-alpha.0

4 years ago

0.1.1-alpha.0

4 years ago