Skip to content

Commit 29f8f1e

Browse files
NickGerlemanLuna Wei
authored andcommitted
Bail on hiPri render on missing layout data before checking priority (#41270)
Summary: Pull Request resolved: #41270 `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 fbshipit-source-id: 8dbffc37edd2a42f7842c0090d344dcd6f3e3c6d
1 parent 832b423 commit 29f8f1e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

packages/virtualized-lists/Lists/VirtualizedList.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1748,8 +1748,9 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
17481748
// If this is triggered in an `componentDidUpdate` followed by a hiPri cellToRenderUpdate
17491749
// We shouldn't do another hipri cellToRenderUpdate
17501750
if (
1751+
(this._listMetrics.getAverageCellLength() > 0 ||
1752+
this.props.getItemLayout != null) &&
17511753
this._shouldRenderWithPriority() &&
1752-
(this._listMetrics.getAverageCellLength() || this.props.getItemLayout) &&
17531754
!this._hiPriInProgress
17541755
) {
17551756
this._hiPriInProgress = true;

0 commit comments

Comments
 (0)