use-size-observer
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

use-size-observer

A custom React hook that leverages the ResizeObserver API to track and measure the dimensions of an element.

Installation

To install the package, use npm:

pnpm add use-size-observer

yarn install use-size-observer

npm install use-size-observer

Usage

import { useSizeObserver } from 'use-size-observer';

const [ref, size] = useSizeObserver();

console.log(size);

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

tsup

Bundle your TypeScript library with no config, powered by esbuild.

https://tsup.egoist.dev/

How to use this

  1. install dependencies
# pnpm
$ pnpm install

# yarn
$ yarn install

# npm
$ npm install
  1. Add your code to src
  2. Add export statement to src/index.tsMessage
  3. Test build command to build src. Once the command works properly, you will see dist folder.
# pnpm
$ pnpm run build

# yarn
$ yarn run build

# npm
$ npm run build
  1. Publish your package
$ npm publish

test package

https://www.npmjs.com/package/use-size-observer

Readme

Keywords

none

Package Sidebar

Install

npm i use-size-observer

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

11.2 kB

Total Files

15

Last publish

Collaborators

  • dimetrix