Skip to content

Latest commit

 

History

History
24 lines (18 loc) · 406 Bytes

useSize.md

File metadata and controls

24 lines (18 loc) · 406 Bytes

useSize

React sensor hook that tracks size of some HTML element.

Usage

import {useSize} from 'react-use';

const Demo = () => {
  const [sized, {width, height}] = useSize(
    ({width}) => <div style={{border: '1px solid red'}}>Size me up! ({width}px)</div>
  );

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