Monitor the size of an element ref.
https://developer.mozilla.org/en-US/docs/Web/API/DOMRectReadOnly
element ref
size and position of a rectangle
import { useResizeObserver } from "@trashpanda001/helpers/react"import { useRef } from "react"function Component() { const ref = useRef<HTMLDivElement>(null) const rect = useResizeObserver(ref) console.log(rect) return <div ref={ref} style={{ width: "100px", height: "100px" }} />} Copy
import { useResizeObserver } from "@trashpanda001/helpers/react"import { useRef } from "react"function Component() { const ref = useRef<HTMLDivElement>(null) const rect = useResizeObserver(ref) console.log(rect) return <div ref={ref} style={{ width: "100px", height: "100px" }} />}
Monitor the size of an element ref.
https://developer.mozilla.org/en-US/docs/Web/API/DOMRectReadOnly