Skip to content

Commit

Permalink
Fix #24053 prevent division by zero error in VirtualizedList debug ov…
Browse files Browse the repository at this point in the history
…erlay (#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
  • Loading branch information
Bartol Karuza authored and facebook-github-bot committed Mar 20, 2019
1 parent 7ae9040 commit 02e8e53
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,8 @@ class VirtualizedList extends React.PureComponent<Props, State> {

_renderDebugOverlay() {
const normalize =
this._scrollMetrics.visibleLength / this._scrollMetrics.contentLength;
this._scrollMetrics.visibleLength /
(this._scrollMetrics.contentLength || 1);
const framesInLayout = [];
const itemCount = this.props.getItemCount(this.props.data);
for (let ii = 0; ii < itemCount; ii++) {
Expand Down

0 comments on commit 02e8e53

Please sign in to comment.