Skip to content

Commit

Permalink
Merge pull request #15434 from chiaweilee/patch-1
Browse files Browse the repository at this point in the history
fix: clearTimeout
  • Loading branch information
afc163 committed Mar 15, 2019
2 parents 729f3b9 + 72296fd commit 4aa32b9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion site/theme/template/IconDisplay/Category.tsx
Expand Up @@ -17,6 +17,8 @@ interface CategoryState {
}

class Category extends React.Component<CategoryProps, CategoryState> {
copyId?: number;

state = {
justCopied: null,
};
Expand All @@ -28,11 +30,15 @@ class Category extends React.Component<CategoryProps, CategoryState> {
</span>,
);
this.setState({ justCopied: type }, () => {
setTimeout(() => {
this.copyId = window.setTimeout(() => {
this.setState({ justCopied: null });
}, 2000);
});
};

componentWillUnmount() {
window.clearTimeout(this.copyId);
}

render() {
const {
Expand Down

0 comments on commit 4aa32b9

Please sign in to comment.