Package Exports
- use-resize-observer
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (use-resize-observer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
use-resize-observer
A React hook that allows you to use a ResizeObserver to measure an element's size.
Install
yarn add use-resize-observer
# or
npm install --save use-resize-observerUsage
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
- Uses resize-observer-polyfill internally, which falls back to the native ResizeObserver, if available.
Related
License
MIT