* Use this custom hook to get access to an element's rect (getBoundingClientRect) * and observe it along time.
(measurable: Measurable | null)
| 6 | * and observe it along time. |
| 7 | */ |
| 8 | function 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 | |
| 23 | export { useRect } |
nothing calls this directly
no test coverage detected
searching dependent graphs…