diff --git a/CHANGELOG.md b/CHANGELOG.md index 88725faff2..13d8b9239f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## v3.0.2 -* Fixed: When no children, or a falsy value, is passed as children to `TableRowExpandable` the row will set the expanded value in this.state to false. +* Fixed: When no children, or a falsy value, is passed as children to `TableRowExpandable` the row will set the expanded value in this.state to false in componentWillReceiveProps. ## v3.0.1 diff --git a/src/TableRowExpandable/TableRowExpandable.js b/src/TableRowExpandable/TableRowExpandable.js index bb22b8a65a..e8c2323c82 100644 --- a/src/TableRowExpandable/TableRowExpandable.js +++ b/src/TableRowExpandable/TableRowExpandable.js @@ -25,14 +25,16 @@ class TableRowExpandable extends Component { } } + componentWillReceiveProps(newProps) { + if (!newProps.children && this.state.expanded) { + this.setState({ expanded: false }); + } + } + render() { const { cells, columns, children } = this.props; const unexpandable = !children; - if (unexpandable && this.state.expanded) { - this.setState({ expanded: false }); - } - return (