From 3041c2d955df438991eeceef193e58c343faceb2 Mon Sep 17 00:00:00 2001 From: Bruno Maia Date: Mon, 26 Oct 2015 17:06:45 +0000 Subject: [PATCH 1/3] Dont check if the same row is expanded multiple times in the same render --- src/Table.jsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Table.jsx b/src/Table.jsx index a60f4945c..aeab9c321 100644 --- a/src/Table.jsx +++ b/src/Table.jsx @@ -124,6 +124,7 @@ const Table = React.createClass({ const record = data[i]; const key = keyFn ? keyFn(record, i) : undefined; const childrenColumn = record[childrenColumnName]; + const isRowExpanded = this.isRowExpanded(record); let expandedRowContent; if (expandedRowRender) { expandedRowContent = expandedRowRender(record, i); @@ -138,13 +139,13 @@ const Table = React.createClass({ visible={visible} onExpand={this.onExpanded} expandable={childrenColumn || expandedRowContent} - expanded={this.isRowExpanded(record)} + expanded={isRowExpanded} prefixCls={`${props.prefixCls}-row`} childrenColumnName={childrenColumnName} columns={columns} key={key}/>); - const subVisible = visible && this.isRowExpanded(record); + const subVisible = visible && isRowExpanded; if (expandedRowContent) { rst.push(this.getExpandedRow(key, expandedRowContent, subVisible, expandedRowClassName(record, i))); From ad961ede60324410526618320677b35b366cc7f1 Mon Sep 17 00:00:00 2001 From: Bruno Maia Date: Mon, 26 Oct 2015 17:07:22 +0000 Subject: [PATCH 2/3] Only call expandedRowRender if the row is expanded --- src/Table.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Table.jsx b/src/Table.jsx index aeab9c321..7ad81d16f 100644 --- a/src/Table.jsx +++ b/src/Table.jsx @@ -126,7 +126,7 @@ const Table = React.createClass({ const childrenColumn = record[childrenColumnName]; const isRowExpanded = this.isRowExpanded(record); let expandedRowContent; - if (expandedRowRender) { + if (expandedRowRender && isRowExpanded) { expandedRowContent = expandedRowRender(record, i); } const className = rowClassName(record, i); From d2fd4a052100e35815d71aa488ef50798eea3f18 Mon Sep 17 00:00:00 2001 From: Bruno Maia Date: Mon, 26 Oct 2015 17:09:32 +0000 Subject: [PATCH 3/3] move isRowExpanded function before render because of linting --- src/Table.jsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Table.jsx b/src/Table.jsx index 7ad81d16f..26a188fd5 100644 --- a/src/Table.jsx +++ b/src/Table.jsx @@ -172,6 +172,13 @@ const Table = React.createClass({ return {cols}; }, + isRowExpanded(record) { + const info = this.state.expandedRows.filter((i) => { + return i.record === record; + }); + return info[0] && info[0].expanded; + }, + render() { const props = this.props; const prefixCls = props.prefixCls; @@ -211,13 +218,6 @@ const Table = React.createClass({ ); }, - - isRowExpanded(record) { - const info = this.state.expandedRows.filter((i) => { - return i.record === record; - }); - return info[0] && info[0].expanded; - }, }); export default Table;