forceUpdate during componentDidUpdate to wait on a computedSTyle

Hello! We have a situation where we need an element to have a clientWidth before continuing with the rest of the calculations. We implemented this

 componentDidUpdate() {
    // Force render until dynamic content is loaded
    if (this.el.clientWidth === 0 && window.getComputedStyle(this.el).display !== 'none') {
      // We need to wait till the end of the tick cycle so that we don't get into an infinite render loop
      setTimeout(() => forceUpdate(this.el), 0);
    }
  }

But I was wondering if there was a better way to avoid this pattern because it creates an infinite loop without the check for window.getComputedStyle(this.el).display !== 'none'. Thank you!