Skip to content
A React hook that allows you to use a ResizeObserver to measure an element's size.
Branch: master
Clone or download

README.md

use-resize-observer

A React hook that allows you to use a ResizeObserver to measure an element's size.

npm version build

In Action

CodeSandbox Demo

Install

yarn add use-resize-observer
# or
npm install --save use-resize-observer

Usage

import React from "react";
import useResizeObserver from "use-resize-observer";

const App = () => {
  const [ref, width, height] = useResizeObserver();

  return (
    <div ref={ref}>
      Size: {width}x{height}
    </div>
  );
};

Notes

Related

License

MIT

You can’t perform that action at this time.