You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP

react-use-rect

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
r

react-use-rect

React hook that measures target element boundaries

0.1.0-alpha.6
Version published
Weekly downloads
1.5K
9.16%
Maintainers
1
Weekly downloads
 
Created
Issues
7

react-use-rect

This hook measures a target element boundaries.

It updates the measure once:

  • the target element size changes;
  • the target element or it's ascendant elements scroll;
  • transitions end.

Installation

npm install react-use-rect

Usage

import React from 'react';
import { useRect } from 'react-use-rect';

function Component() {
  const [ref, rect] = useRect();

  return <div ref={ref} />;
}

Options

The hook accepts an object of options as it's only argument.

scroll

boolean

default: true

Enables listening to scroll changes.

transitionEnd

boolean

default: true

Enables listening to transition ends.

FAQs

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