From 3b496b04341c62c443cb7f3b436bbb617848a251 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Tue, 31 Oct 2023 13:46:26 -0700 Subject: [PATCH] Bail on hiPri render on missing layout data before checking priority Summary: `scheduleCellsToRenderUpdate()` is called in response to new measurements, or component changes. It has logic to decide whether to immediately calculate new state, or to defer it until a later batched period. It will not immediately update state if we don't yet have measurements for cells, but this condition is after another which calculates priority, relying on these measurements. These are garbage if we don't yet have measurements, and trigger an invariant violation in horizontal RTL. This switches around the conditions, to avoid offset resolution if we don't yet have valid measurements. I suspect some "hiPri" renders where cells shift are bugged right now when we update state in response to content size change, before we have new corresponding cell layouts. Changelog: [General][Fixed] - Bail on hiPri render on missing layout data before checking priority Reviewed By: yungsters Differential Revision: D50791506 --- packages/virtualized-lists/Lists/VirtualizedList.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/virtualized-lists/Lists/VirtualizedList.js b/packages/virtualized-lists/Lists/VirtualizedList.js index 886e2ec657be0b..f257a0dc585990 100644 --- a/packages/virtualized-lists/Lists/VirtualizedList.js +++ b/packages/virtualized-lists/Lists/VirtualizedList.js @@ -1752,8 +1752,9 @@ class VirtualizedList extends StateSafePureComponent { // If this is triggered in an `componentDidUpdate` followed by a hiPri cellToRenderUpdate // We shouldn't do another hipri cellToRenderUpdate if ( + (this._listMetrics.getAverageCellLength() > 0 || + this.props.getItemLayout != null) && this._shouldRenderWithPriority() && - (this._listMetrics.getAverageCellLength() || this.props.getItemLayout) && !this._hiPriInProgress ) { this._hiPriInProgress = true;