Skip to content

Commit

Permalink
Remove wrapper around ListEmptyComponent (#24339)
Browse files Browse the repository at this point in the history
Summary:
This pull request fixes #24257.

The wrapper around ListEmptyComponent doesn't allow to use flex on the ListEmptyComponent.
The wrapper was removed in this [commit](db061ea), and then put back in this [commit](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: #24339

Differential Revision: D14822221

Pulled By: cpojer

fbshipit-source-id: 623e1ab3f228e9b75b92cdcd568683232a403c1a
  • Loading branch information
AntoineDoubovetzky authored and facebook-github-bot committed Apr 8, 2019
1 parent e5d975b commit 4627644
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
24 changes: 13 additions & 11 deletions Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -873,17 +873,19 @@ class VirtualizedList extends React.PureComponent<Props, State> {
<ListEmptyComponent />
)): any);
cells.push(
<View key="$empty" style={inversionStyle}>
{React.cloneElement(element, {
onLayout: event => {
this._onLayoutEmpty(event);
if (element.props.onLayout) {
element.props.onLayout(event);
}
},
style: element.props.style,
})}
</View>,
React.cloneElement(element, {
key: '$empty',
onLayout: event => {
this._onLayoutEmpty(event);
if (element.props.onLayout) {
element.props.onLayout(event);
}
},
style: StyleSheet.compose(
inversionStyle,
element.props.style,
),
}),
);
}
if (ListFooterComponent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -668,11 +668,7 @@ exports[`VirtualizedList renders empty list with empty component 1`] = `
>
<header />
</View>
<View
style={null}
>
<empty />
</View>
<empty />
<View
onLayout={[Function]}
>
Expand Down

0 comments on commit 4627644

Please sign in to comment.