Skip to content

Commit a3d358b

Browse files
Merge pull request #296 from HyopeR/master
Stabilize the unstable empty component.
2 parents 96d9134 + 5c45335 commit a3d358b

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

lib/BigList.jsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -685,10 +685,11 @@ class BigList extends PureComponent {
685685
// On empty list
686686
const isEmptyList = this.isEmpty();
687687
const emptyItem = ListEmptyComponent
688-
? createElement(ListEmptyComponent)
688+
? createElement(ListEmptyComponent, {style: fullItemStyle})
689689
: renderEmpty
690-
? renderEmpty()
690+
? createElement(renderEmpty(), {style: fullItemStyle})
691691
: null;
692+
692693
if (isEmptyList && emptyItem) {
693694
if (hideMarginalsOnEmpty || (hideHeaderOnEmpty && hideFooterOnEmpty)) {
694695
// Render empty
@@ -700,7 +701,7 @@ class BigList extends PureComponent {
700701
);
701702
items.splice(headerIndex + 1, 0, {
702703
type: BigListItemType.EMPTY,
703-
key: "empty",
704+
key: 'empty',
704705
});
705706
if (hideHeaderOnEmpty) {
706707
// Hide header
@@ -809,7 +810,11 @@ class BigList extends PureComponent {
809810
}
810811
break;
811812
case BigListItemType.EMPTY:
812-
children.push(<View key={itemKey}>{emptyItem}</View>);
813+
children.push(
814+
<React.Fragment key={itemKey}>
815+
{emptyItem}
816+
</React.Fragment>
817+
);
813818
break;
814819
case BigListItemType.SPACER:
815820
children.push(
@@ -985,8 +990,6 @@ class BigList extends PureComponent {
985990
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
986991
) : null,
987992
contentContainerStyle: {
988-
flexDirection: "row",
989-
flexWrap: "wrap",
990993
maxWidth: "100%",
991994
},
992995
};

lib/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export type BigListRenderItem<ItemT> = (
2222
info: BigListRenderItemInfo<ItemT>,
2323
) => React.ReactElement | null;
2424

25-
interface BigListProps<ItemT>
25+
export interface BigListProps<ItemT>
2626
extends ScrollViewProps,
2727
Pick<
2828
FlatListProps<ItemT>,

lib/utils.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,15 @@ export const mergeViewStyle = (style, defaultStyle = {}) => {
125125
/**
126126
* Get element from component.
127127
* @param {React.node} Component
128+
* @param props
128129
* @returns {JSX.Element|[]|*}
129130
*/
130-
export const createElement = (Component) => {
131+
export const createElement = (Component, props) => {
131132
return Component != null ? (
132133
React.isValidElement(Component) ? (
133-
Component
134+
React.cloneElement(Component, props)
134135
) : (
135-
<Component />
136+
<Component {...props} />
136137
)
137138
) : null;
138139
};

0 commit comments

Comments
 (0)