From e85238b3fc32610d5c27340f87377a0a54df49a5 Mon Sep 17 00:00:00 2001 From: Jin Date: Mon, 8 Jul 2019 22:59:57 +0800 Subject: [PATCH] fix(Tooltip): clear timeouts on unmount (#1562) Fixes #1255 --- src/TooltipPopoverWrapper.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/TooltipPopoverWrapper.js b/src/TooltipPopoverWrapper.js index 2d3783a65..29f8feeed 100644 --- a/src/TooltipPopoverWrapper.js +++ b/src/TooltipPopoverWrapper.js @@ -82,14 +82,19 @@ class TooltipPopoverWrapper extends React.Component { this.getRef = this.getRef.bind(this); this.onClosed = this.onClosed.bind(this); this.state = { isOpen: props.isOpen }; + this._isMounted = false; } componentDidMount() { + this._isMounted = true; this.updateTarget(); } componentWillUnmount() { + this._isMounted = false; this.removeTargetEvents(); + this.clearShowTimeout(); + this.clearHideTimeout(); } static getDerivedStateFromProps(props, state) { @@ -279,7 +284,7 @@ class TooltipPopoverWrapper extends React.Component { } toggle(e) { - if (this.props.disabled) { + if (this.props.disabled || !this._isMounted) { return e && e.preventDefault(); }