diff --git a/src/components/CurrentAddress/index.js b/src/components/CurrentAddress/index.js index 488bf105..bf979fbc 100644 --- a/src/components/CurrentAddress/index.js +++ b/src/components/CurrentAddress/index.js @@ -143,7 +143,26 @@ class CurrentAddress extends PureComponent { copyFeedback: false, } - _isUnmounted = false + componentWillUnmount() { + if (this._timeout) clearTimeout(this._timeout) + } + + renderCopy = copy => { + const { t } = this.props + return ( + } + label={t('app:common.copyAddress')} + onClick={() => { + this.setState({ copyFeedback: true }) + this._timeout = setTimeout(() => this.setState({ copyFeedback: false }), 1e3) + copy() + }} + /> + ) + } + + _timeout: ?TimeoutID = null render() { const { @@ -214,23 +233,7 @@ class CurrentAddress extends PureComponent { onClick={onVerify} /> ) : null} - ( - } - label={t('app:common.copyAddress')} - onClick={() => { - this.setState({ copyFeedback: true }) - setTimeout(() => { - if (this._isUnmounted) return - this.setState({ copyFeedback: false }) - }, 1e3) - copy() - }} - /> - )} - /> + )