Skip to content

Use Size React is a react hook to track size of HTML element by passing ref

License

Notifications You must be signed in to change notification settings

kastet777/use-size

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Use Size React

Use Size React is a react hook to track size of HTML element by passing ref.

Install

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

Usage

import React from 'react';
import {useSize} from 'use-size-react';

const App = () => {
  const {ref, size: {width, height}} = useSize();

  return (
    <div>
      <p>Track div size</p>
      <div ref={ref}>
        width: {width} {'  '} height: {height}
      </div>
    </div>
  );
}

License

MIT

About

Use Size React is a react hook to track size of HTML element by passing ref

Resources

License

Stars

Watchers

Forks

Packages

No packages published