MCPcopy Create free account
hub / github.com/editablejs/editable / useRect

Function useRect

packages/ui/src/hooks/use-rect.ts:8–21  ·  view source on GitHub ↗

* Use this custom hook to get access to an element's rect (getBoundingClientRect) * and observe it along time.

(measurable: Measurable | null)

Source from the content-addressed store, hash-verified

6 * and observe it along time.
7 */
8function useRect(measurable: Measurable | null) {
9 const [rect, setRect] = React.useState<ClientRect>()
10 React.useEffect(() => {
11 if (measurable) {
12 const unobserve = observeElementRect(measurable, setRect)
13 return () => {
14 setRect(undefined)
15 unobserve()
16 }
17 }
18 return
19 }, [measurable])
20 return rect
21}
22
23export { useRect }

Callers

nothing calls this directly

Calls 1

observeElementRectFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…