mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #9705 from darkwing/avoid-selected-account-memory-leak
Prevent memory leak from selected account copy tooltip
This commit is contained in:
commit
f15b4949a1
@ -18,6 +18,17 @@ class SelectedAccount extends Component {
|
|||||||
selectedIdentity: PropTypes.object.isRequired,
|
selectedIdentity: PropTypes.object.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidMount () {
|
||||||
|
this.copyTimeout = null
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount () {
|
||||||
|
if (this.copyTimeout) {
|
||||||
|
clearTimeout(this.copyTimeout)
|
||||||
|
this.copyTimeout = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { t } = this.context
|
const { t } = this.context
|
||||||
const { selectedIdentity } = this.props
|
const { selectedIdentity } = this.props
|
||||||
@ -34,7 +45,7 @@ class SelectedAccount extends Component {
|
|||||||
className="selected-account__clickable"
|
className="selected-account__clickable"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
this.setState({ copied: true })
|
this.setState({ copied: true })
|
||||||
setTimeout(() => this.setState({ copied: false }), 3000)
|
this.copyTimeout = setTimeout(() => this.setState({ copied: false }), 3000)
|
||||||
copyToClipboard(checksummedAddress)
|
copyToClipboard(checksummedAddress)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user