Fix string rowKey in Table, close #2500

ref #2058
This commit is contained in:
afc163 2016-07-26 21:14:13 +08:00
parent f862655df5
commit f4b10a9e7c

View File

@ -58,6 +58,7 @@ export default class Table extends React.Component {
indentSize: 20,
onChange: noop,
locale: {},
rowKey: 'key',
}
static contextTypes = {
@ -486,10 +487,11 @@ export default class Table extends React.Component {
}
getRecordKey(record, index) {
if (this.props.rowKey) {
return this.props.rowKey(record, index);
const { rowKey } = this.props;
if (typeof rowKey === 'function') {
return rowKey(record, index);
}
return record.key || index;
return record[rowKey] || index;
}
renderRowSelection() {