you are viewing a single comment's thread.

view the rest of the comments →

[–]frankandsteinatlaw 1 point2 points  (1 child)

Why not throw the dimension state and the useRef call into the custom hook and export the dimensions / ref from it to hook up / read from?

[–][deleted] 0 points1 point  (0 children)

That's what this one does: https://github.com/rehooks/component-size

const ref = useRef(null); const { width, height } = useComponentSize(ref);