Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

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

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

React hook written in TypeScript

latest
Source
npmnpm
Version
1.0.5
Version published
Weekly downloads
4
-88.24%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

react

FAQs

Package last updated on 06 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts