Skip to content

Commit

Permalink
DIG-21418 componentWillReceiveProps ftw - not change state in render
Browse files Browse the repository at this point in the history
  • Loading branch information
trulsbjo committed Mar 7, 2017
1 parent 2c2990b commit d5a4a4f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 6 additions & 4 deletions src/TableRowExpandable/TableRowExpandable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<tbody>
<TableRow
Expand Down

0 comments on commit d5a4a4f

Please sign in to comment.