From a46f4a604939bfdcd96fd784002a5bcb06ab45e8 Mon Sep 17 00:00:00 2001 From: Richard Samuelsson Date: Tue, 19 Mar 2019 14:39:52 +0100 Subject: [PATCH] fix(react-transition-collapse): make sure null is not the arg to DOMEl contains func --- README.md | 7 ++++--- src/react-transition-collapse.tsx | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) 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 {