# 在 Remotion 中测量 DOM 节点
Remotion 会对视频容器应用 `scale()` 变换,这会影响 `getBoundingClientRect()` 的返回值。请使用 `useCurrentScale()` 来获取正确的测量值。
## 测量元素尺寸
tsx
import { useCurrentScale } from "remotion";
import { useRef, useEffect, useState } from "react";
export const MyComponent = () => {
const ref = useRef(null);
const scale = useCurrentScale();
const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
useEffect(() => {
if (!ref.current) return;
const rect = ref.current.getBoundingClientRect();
setDimensions({
width: rect.width / scale,
height: rect.height / scale,
});
}, [scale]);
return
要测量的内容
;
};