Skip to content

Commit

Permalink
Merge pull request #546 from shoutem/release/4.0.14
Browse files Browse the repository at this point in the history
Release/4.0.14
  • Loading branch information
majaklajic authored Nov 24, 2020
2 parents 12524c3 + fc61949 commit e97e9a8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
24 changes: 22 additions & 2 deletions components/ListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class ListView extends PureComponent {

// if list is empty, show empty placeholder
if (!ListEmptyComponent) {
mappedProps.ListEmptyComponent = EmptyListImage;
mappedProps.ListEmptyComponent = this.renderListEmptyComponent();
}

// refresh control
Expand Down Expand Up @@ -281,6 +281,20 @@ class ListView extends PureComponent {
);
}

renderListEmptyComponent() {
const { ListEmptyComponent, loading } = this.props

if (loading) {
return null;
}

if (ListEmptyComponent) {
return <ListEmptyComponent />;
}

<EmptyListImage />
}

renderRefreshControl() {
const { style } = this.props;
const { status } = this.state;
Expand All @@ -300,7 +314,13 @@ class ListView extends PureComponent {
}

render() {
const { sections, hasFeaturedItem } = this.props;
const { sections, hasFeaturedItem, ListEmptyComponent, loading } = this.props;

/* ListEmptyComponent in SectionList is handled differently due to the known issue with empty data interpretation.
https://github.com/facebook/react-native/issues/14721 */
if (sections && _.every(sections, (section) => _.isEmpty(section.data)) && !loading) {
return ListEmptyComponent ? <ListEmptyComponent /> : <EmptyListImage />;
}

if (sections || hasFeaturedItem) {
return <SectionList {...this.getPropsToPass()} />;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shoutem/ui",
"version": "4.0.13",
"version": "4.0.14",
"description": "Styleable set of components for React Native applications",
"dependencies": {
"@shoutem/animation": "~0.12.4",
Expand Down

0 comments on commit e97e9a8

Please sign in to comment.