Fix rowKey usages in List (#14437)

* correct rowKey usages in List

* fix item type in renderItem in List
This commit is contained in:
Aobo Yang 2019-02-21 21:40:30 -05:00 committed by zombieJ
parent 8f7d4970a5
commit 1f0166c156

View File

@ -97,16 +97,16 @@ export default class List extends React.Component<ListProps> {
};
}
renderItem = (item: React.ReactElement<any>, index: number) => {
const { dataSource, renderItem, rowKey } = this.props;
renderItem = (item: any, index: number) => {
const { renderItem, rowKey } = this.props;
let key;
if (typeof rowKey === 'function') {
key = rowKey(dataSource[index]);
key = rowKey(item);
} else if (typeof rowKey === 'string') {
key = dataSource[rowKey];
key = item[rowKey];
} else {
key = dataSource.key;
key = item.key;
}
if (!key) {