Github https://github.com/maslianok/react-resize-detector
npmjs https://www.npmjs.com/package/react-resize-detector
在线案例 http://maslianok.github.io/react-resize-detector/
监听 DOM,宽高改变,代替 Resize Detector https://www.npmjs.com/package/resize-detector
yarn add react-resize-detector
import { useResizeDetector } from 'react-resize-detector';
const CustomComponent = () => {
const { width, height, ref } = useResizeDetector();
return <div ref={ref}>{`${width}x${height}`}</div>;
};