Browse Source

fix(dashboard): Check if big number height has changed before setting state (#34046)

We're currently relying on the ref to calculate a height for the big
number widget. A small set of users are hitting a recursion depth issue
with setState. Add a conditional so we aren't calling it unless
necessary (i.e. the size has changed).

Fixes JAVASCRIPT-26WN
Nar Saynorath 2 years ago
parent
commit
d5b649d7a2
1 changed files with 3 additions and 1 deletions
  1. 3 1
      static/app/views/dashboardsV2/widgetCard/chart.tsx

+ 3 - 1
static/app/views/dashboardsV2/widgetCard/chart.tsx

@@ -293,7 +293,9 @@ class WidgetCardChart extends React.Component<WidgetCardChartProps, State> {
             ref={el => {
               if (el !== null && !!!expandNumbers) {
                 const {height} = el.getBoundingClientRect();
-                this.setState({containerHeight: height});
+                if (height !== this.state.containerHeight) {
+                  this.setState({containerHeight: height});
+                }
               }
             }}
           >