From f4b10a9e7c0041cc1a59d2bbd709f13eadcf0dfa Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 26 Jul 2016 21:14:13 +0800 Subject: [PATCH] Fix string rowKey in Table, close #2500 ref #2058 --- components/table/Table.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/table/Table.jsx b/components/table/Table.jsx index 4e1bfde61a..0ecefa449c 100644 --- a/components/table/Table.jsx +++ b/components/table/Table.jsx @@ -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() {