Use Ref Callbacks to Measure React Component Size

You can use ref callbacks to measure the rendered size of React components, did you know? It’s a neat little trick.
Here’s how it works:1. React renders your component.2. Browser layout engine does its thing.3. ref callback fires.4. Use getBoundingClientRect to measure element size.5. Use this info for whatever you want.

Link: https://dzone.com/articles/use-ref-callbacks-to-measure-react-component-size?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev