🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

use-size-performant

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-size-performant

> React hook to retrieve the size of an element

latest
Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
9
-59.09%
Maintainers
1
Weekly downloads
 
Created
Source

use-size-performant

React hook to retrieve the size of an element

NPM

Installation

npm i use-size-performant
// or
yarn add use-size-performant

Usage

Using Ref

import useSize from "use-size-performant";
const YourComponent = () => {
  const ref = useRef(null);
  const { height, width } = useSize(ref);
  return (
    <div ref={ref}>
      <p>Height: {height}</p>
      <p>Width: {width}</p>
    </div>
  );
};

Using DOM elements

import useSize from "use-size-performant";
const YourComponent = () => {
  const dom = document.querySelector('body');
  const { height, width } = useSize(dom);
  return (
    <div>
      <p>Height: {height}</p>
      <p>Width: {width}</p>
    </div>
  );
};

License

MIT © Akshit Kr Nagpal

FAQs

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