diff --git a/src/Collapse.js b/src/Collapse.js index a002023..e10915b 100644 --- a/src/Collapse.js +++ b/src/Collapse.js @@ -64,19 +64,6 @@ export class Collapse extends React.Component { || Object.keys(theme).some(c => theme[c] !== nextProps.theme[c]); } - - getSnapshotBeforeUpdate() { - if (!this.container || !this.content) { - return null; - } - if (this.container.style.height === 'auto') { - const {clientHeight: contentHeight} = this.content; - this.container.style.height = `${contentHeight}px`; - } - return null; - } - - componentDidUpdate() { this.onResize(); } @@ -94,6 +81,11 @@ export class Collapse extends React.Component { return; } + if (this.container.style.height === 'auto') { + const {clientHeight: contentHeight} = this.content; + this.container.style.height = `${contentHeight}px`; + } + const {isOpened, checkTimeout} = this.props; const containerHeight = Math.floor(this.container.clientHeight); const contentHeight = Math.floor(this.content.clientHeight);