Skip to content

Commit

Permalink
Fix verticalAccordion componentDidUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusd committed Nov 30, 2018
1 parent 0100e88 commit 6b1413e
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions app/components/shared/VerticalAccordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,15 @@ class VerticalAccordion extends React.Component {
}

componentDidUpdate(prevProps) {
let oldChildren, newChildren, newKeys;
let needUpdate = false;
if(prevProps.children) {
oldChildren = prevProps.children;
}
if (this.props.children) {
newChildren = this.props.children;
newKeys = Object.keys(newChildren.props);
}
if (oldChildren && newChildren) {
newKeys.forEach( key => {
if (typeof(newChildren.props[key]) !== "object" &&
typeof(newChildren.props[key]) !== "function") {
if (oldChildren.props[key] !== newChildren.props[key]) {
needUpdate = true;
return;
}
}
});
}
const needUpdate =
(prevProps.show !== this.props.show) ||
(prevProps.children !== this.props.children) ||
(prevProps.height !== this.props.height);

if (prevProps.show !== this.props.show || needUpdate) {
if (needUpdate) {
this.setState({
shownStyles: this.chosenStyles(this.props, this.props.show),
});
this.chosenStyles(this.props, this.props.show);
}
}

Expand Down

0 comments on commit 6b1413e

Please sign in to comment.