Skip to content

Commit

Permalink
Merge pull request ant-design#16081 from raybooysen/fix/cancelExistin…
Browse files Browse the repository at this point in the history
…gDebounce

fix: If there is an existing debounce in progress, cancel that
  • Loading branch information
afc163 authored Apr 15, 2019
2 parents d9d189e + fe1617b commit 321a12e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions components/spin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ class Spin extends React.Component<SpinProps, SpinState> {
}

componentWillUnmount() {
this.cancelExistingSpin();
}

cancelExistingSpin() {
const updateSpinning: any = this.updateSpinning;
if (updateSpinning && updateSpinning.cancel) {
updateSpinning.cancel();
Expand All @@ -116,6 +120,7 @@ class Spin extends React.Component<SpinProps, SpinState> {
debouncifyUpdateSpinning = (props?: SpinProps) => {
const { delay } = props || this.props;
if (delay) {
this.cancelExistingSpin();
this.updateSpinning = debounce(this.originalUpdateSpinning, delay);
}
};
Expand Down

0 comments on commit 321a12e

Please sign in to comment.