react-use/docs/useMeasure.md
2019-08-23 18:53:41 +08:00

358 B

useSize

React sensor hook that tracks size of an HTML element.

Usage

import { useMeasure } from "react-use";

const Demo = () => {
  const [ref, { width, height }] = useSize();

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