Skip to content

Commit 09501c2

Browse files
committed
Unique key problem fix.
1 parent ba456e1 commit 09501c2

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

lib/BigList.jsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -683,10 +683,7 @@ class BigList extends PureComponent {
683683
});
684684

685685
const getEmpty = () => {
686-
const props = {
687-
key: 'empty',
688-
style: fullItemStyle
689-
};
686+
const props = {style: fullItemStyle};
690687

691688
return ListEmptyComponent
692689
? createElement(ListEmptyComponent, props)
@@ -709,6 +706,7 @@ class BigList extends PureComponent {
709706
);
710707
items.splice(headerIndex + 1, 0, {
711708
type: BigListItemType.EMPTY,
709+
key: 'empty',
712710
});
713711
if (hideHeaderOnEmpty) {
714712
// Hide header
@@ -817,7 +815,11 @@ class BigList extends PureComponent {
817815
}
818816
break;
819817
case BigListItemType.EMPTY:
820-
children.push(getEmpty());
818+
children.push(
819+
<React.Fragment key={itemKey}>
820+
{getEmpty()}
821+
</React.Fragment>
822+
);
821823
break;
822824
case BigListItemType.SPACER:
823825
children.push(

lib/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export const mergeViewStyle = (style, defaultStyle = {}) => {
131131
export const createElement = (Component, ...props) => {
132132
return Component != null ? (
133133
React.isValidElement(Component) ? (
134-
Component
134+
React.cloneElement(Component, props)
135135
) : (
136136
<Component {...props} />
137137
)

0 commit comments

Comments
 (0)