Skip to content

Commit

Permalink
Prevents bad behaviour when dynamic children
Browse files Browse the repository at this point in the history
  • Loading branch information
evilchis94 committed Nov 11, 2017
1 parent 7e5c334 commit 40bdbd1
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions Collapsible.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,24 @@ export default class Collapsible extends Component {
}

componentWillReceiveProps(nextProps) {
if (nextProps.collapsed !== this.props.collapsed) {
this._toggleCollapsed(nextProps.collapsed);
} else if (
nextProps.collapsed &&
nextProps.collapsedHeight !== this.props.collapsedHeight
) {
this.state.height.setValue(nextProps.collapsedHeight);
if (!nextProps.collapsed && !this.props.collapsed) {
this.setState({measured: false}, () => this._componentWillReceiveProps(nextProps));
} else {
this._componentWillReceiveProps(nextProps);
}
}

_componentWillReceiveProps(nextProps) {
if (nextProps.collapsed !== this.props.collapsed) {
this._toggleCollapsed(nextProps.collapsed);
} else if (
nextProps.collapsed &&
nextProps.collapsedHeight !== this.props.collapsedHeight
) {
this.state.height.setValue(nextProps.collapsedHeight);
}
}

contentHandle = null;

_handleRef = ref => {
Expand Down

0 comments on commit 40bdbd1

Please sign in to comment.