diff --git a/README.md b/README.md index 968c9a8..9b08bde 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,12 @@ yarn add react-transition-collapse ### Usage -ReactTransitionCollapse takes three props: +ReactTransitionCollapse takes these props: ``` -expanded: boolean -duration: number | string // number of milliseconds children: Element +duration: number | string // number of milliseconds +expanded: boolean +animationType: 'scale' | 'translate' // which css transform should be applied to animate the transition ``` #### Full example diff --git a/src/react-transition-collapse.tsx b/src/react-transition-collapse.tsx index 4b9e66c..c411922 100644 --- a/src/react-transition-collapse.tsx +++ b/src/react-transition-collapse.tsx @@ -60,7 +60,7 @@ class ReactTransitionCollapse extends React.PureComponent { reMeasure = () => { let timeout: NodeJS.Timeout return this.getListener(() => { - if (!this.wrapperEl || !this.wrapperEl.contains(this.innerEl)) { + if (!this.wrapperEl || !this.innerEl || !this.wrapperEl.contains(this.innerEl)) { return } clearTimeout(timeout) @@ -101,7 +101,7 @@ class ReactTransitionCollapse extends React.PureComponent { this.wrapperEl.appendChild(this.innerEl) const reexec = () => requestAnimationFrame(() => { - if (this.wrapperEl && this.wrapperEl.contains(this.innerEl)) { + if (this.wrapperEl && this.innerEl && this.wrapperEl.contains(this.innerEl)) { this.measure(this.innerEl) this.updateInnerHeight(this.height) } else {