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.