From 160dede41254f4d47aa985cfda720271ad784270 Mon Sep 17 00:00:00 2001 From: AllenFang Date: Sun, 7 Apr 2019 17:33:00 +0800 Subject: [PATCH] fix #898 --- .../src/contexts/row-expand-context.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/react-bootstrap-table2/src/contexts/row-expand-context.js b/packages/react-bootstrap-table2/src/contexts/row-expand-context.js index 601c338..0c4789a 100644 --- a/packages/react-bootstrap-table2/src/contexts/row-expand-context.js +++ b/packages/react-bootstrap-table2/src/contexts/row-expand-context.js @@ -17,13 +17,17 @@ class RowExpandProvider extends React.Component { componentWillReceiveProps(nextProps) { if (nextProps.expandRow) { + const nextExpanded = nextProps.expandRow.expanded || this.state.expanded; const isClosing = this.state.expanded.reduce((acc, cur) => { - if (!nextProps.expandRow.expanded.includes(cur)) { + if (!nextExpanded.includes(cur)) { acc.push(cur); } return acc; }, []); - this.setState(() => ({ expanded: nextProps.expandRow.expanded, isClosing })); + this.setState(() => ({ + expanded: nextExpanded, + isClosing + })); } else { this.setState(() => ({ expanded: this.state.expanded