Skip to content

Commit d7e7b3e

Browse files
Bartol Karuzakelset
authored andcommitted
Fix #24053 prevent division by zero error in VirtualizedList debug overlay (#24058)
Summary: This PR fixes the case where the content a VirtualizedList loads with a contentLength of 0, causing a crash in the `renderDebugOverlay` function. The result of that crash is a red screen when turning on debug on FlatList and other VirtualizedList components as described in #24053. [LIST] [FIX] - Fix VirtualizedList debug mode crash Pull Request resolved: #24058 Differential Revision: D14538317 Pulled By: cpojer fbshipit-source-id: 7b17bf51c388561c517bab1f775a31200abdc5a9
1 parent 871290f commit d7e7b3e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Libraries/Lists/VirtualizedList.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,8 @@ class VirtualizedList extends React.PureComponent<Props, State> {
11811181

11821182
_renderDebugOverlay() {
11831183
const normalize =
1184-
this._scrollMetrics.visibleLength / this._scrollMetrics.contentLength;
1184+
this._scrollMetrics.visibleLength /
1185+
(this._scrollMetrics.contentLength || 1);
11851186
const framesInLayout = [];
11861187
const itemCount = this.props.getItemCount(this.props.data);
11871188
for (let ii = 0; ii < itemCount; ii++) {

0 commit comments

Comments
 (0)