Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-window-size-hooks

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-window-size-hooks

Reactivity window size for React.

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
34
decreased by-44.26%
Maintainers
1
Weekly downloads
 
Created
Source

react-window-size-hooks

npm version License: MIT CI Status

React hooks to get the window size.

Install

npm

$ npm i react-window-size-hooks

yarn

$ yarn add react-window-size-hooks

Usage

import React from 'react';
import { useWindowSize } from 'react-window-size-hooks';

export const ShowWindowSize = () => {
  const { width, height } = useWindowSize();
  // do something
};

use only the width or height

import React from 'react';
import { useWindowWidth, useWindowHeight } from 'react-window-size-hooks';

export const ShowWindowSize = () => {
  const width = useWindowWidth();
  const height = useWindowHeight();
  // do something
};

used in SSR

Set an arbitrary initial value. If not set, the size is 0.

import React from 'react';
import { useWindowSize } from 'react-window-size-hooks';

export const ShowWindowSize = () => {
  const { width, height } = useWindowSize({
    width: 800,
    height: 600,
  });
  // do something
};

FAQ

What is the interval between Throttling?

33ms. It's about 30FPS.

What are the characteristics of the react-window-size-hooks?

  • Only one resize event is registered, even if used in multiple locations.
    • Throttling is also done in one place, which is efficient.
  • Supports TypeScript.

Contribution

If you find a bug or want to contribute to the code or documentation, you can help by submitting an issue or a pull request.

License

MIT

Keywords

FAQs

Package last updated on 26 Sep 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc