/**
* title: 基本用法
* desc: 使用 ref 监听节点尺寸变化
*/
import React, { useRef } from 'react';
import useSize from "../../useSize";
function Demo2(): JSX.Element {
const dom = document.querySelector('body');
const size = useSize(dom);
return (
try to resize the preview window
dimensions -- width: {size.width} px, height: {size.height} px
);
}
export default () => {
const ref = useRef();
const size = useSize(ref);
return (
<>
try to resize the preview window
dimensions -- width: {size.width} px, height: {size.height} px
>
);
};