Skip to content

Commit

Permalink
fix: prevent setting virtualized list size to zero
Browse files Browse the repository at this point in the history
Can happen when using a tab navigator for example, page is still mounted so onlayout will be triggered, but size will be set to 0
  • Loading branch information
JulienIzz committed Mar 21, 2024
1 parent 30ecb97 commit df9d1c1
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ export const VirtualizedListWithSize = typedMemo(
onLayout={(event) => {
if (!hasAlreadyRendered) {
const sizeKey = isVertical ? 'height' : 'width';
setListSizeInPx(event.nativeEvent.layout[sizeKey]);
setHasAlreadyRendered(true);
if (event.nativeEvent.layout[sizeKey] !== 0) {
setListSizeInPx(event.nativeEvent.layout[sizeKey]);
setHasAlreadyRendered(true);
}
}
}}
testID={props.testID ? props.testID + '-size-giver' : undefined}
Expand Down

0 comments on commit df9d1c1

Please sign in to comment.