MCPcopy Create free account
hub / github.com/OpenPipe/OpenPipe / useElementDimensions

Function useElementDimensions

app/src/utils/hooks.ts:58–84  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

56
57// get dimensions of an element
58export const useElementDimensions = (): [RefObject<HTMLElement>, Dimensions | undefined] => {
59 const ref = useRef<HTMLElement>(null);
60 const [dimensions, setDimensions] = useState<Dimensions | undefined>();
61
62 useEffect(() => {
63 if (ref.current) {
64 const observer = new ResizeObserver((entries) => {
65 entries.forEach((entry) => {
66 setDimensions(entry.contentRect);
67 });
68 });
69
70 const observedRef = ref.current;
71
72 observer.observe(observedRef);
73
74 // Cleanup the observer on component unmount
75 return () => {
76 if (observedRef) {
77 observer.unobserve(observedRef);
78 }
79 };
80 }
81 }, []);
82
83 return [ref, dimensions];
84};
85
86export const useIsMissingBetaAccess = () => !useActiveFeatureFlags()?.includes("betaAccess");
87

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected