Skip to content

Commit 3c8def4

Browse files
AntoineDoubovetzkyzhongwuzw
AntoineDoubovetzky
authored andcommitted
Remove wrapper around ListEmptyComponent (facebook#24339)
Summary: This pull request fixes facebook#24257. The wrapper around ListEmptyComponent doesn't allow to use flex on the ListEmptyComponent. The wrapper was removed in this [commit](facebook@db061ea), and then put back in this [commit](facebook@e94d344) but I think the relevant part was removing the condition on `itemCount !== 0` to apply the inversionStyle on the ScrollView and everything is still working without the wrapper. [GENERAL] [FIXED] - Remove wrapper around ListEmptyComponent Pull Request resolved: facebook#24339 Differential Revision: D14822221 Pulled By: cpojer fbshipit-source-id: 623e1ab3f228e9b75b92cdcd568683232a403c1a
1 parent dea5eae commit 3c8def4

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

Libraries/Lists/VirtualizedList.js

+13-11
Original file line numberDiff line numberDiff line change
@@ -873,17 +873,19 @@ class VirtualizedList extends React.PureComponent<Props, State> {
873873
<ListEmptyComponent />
874874
)): any);
875875
cells.push(
876-
<View key="$empty" style={inversionStyle}>
877-
{React.cloneElement(element, {
878-
onLayout: event => {
879-
this._onLayoutEmpty(event);
880-
if (element.props.onLayout) {
881-
element.props.onLayout(event);
882-
}
883-
},
884-
style: element.props.style,
885-
})}
886-
</View>,
876+
React.cloneElement(element, {
877+
key: '$empty',
878+
onLayout: event => {
879+
this._onLayoutEmpty(event);
880+
if (element.props.onLayout) {
881+
element.props.onLayout(event);
882+
}
883+
},
884+
style: StyleSheet.compose(
885+
inversionStyle,
886+
element.props.style,
887+
),
888+
}),
887889
);
888890
}
889891
if (ListFooterComponent) {

Libraries/Lists/__tests__/__snapshots__/VirtualizedList-test.js.snap

+1-5
Original file line numberDiff line numberDiff line change
@@ -668,11 +668,7 @@ exports[`VirtualizedList renders empty list with empty component 1`] = `
668668
>
669669
<header />
670670
</View>
671-
<View
672-
style={null}
673-
>
674-
<empty />
675-
</View>
671+
<empty />
676672
<View
677673
onLayout={[Function]}
678674
>

0 commit comments

Comments
 (0)