mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-03 04:30:06 +08:00
Merge pull request #16081 from raybooysen/fix/cancelExistingDebounce
fix: If there is an existing debounce in progress, cancel that
This commit is contained in:
commit
321a12eb6c
@ -98,6 +98,10 @@ class Spin extends React.Component<SpinProps, SpinState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
this.cancelExistingSpin();
|
||||||
|
}
|
||||||
|
|
||||||
|
cancelExistingSpin() {
|
||||||
const updateSpinning: any = this.updateSpinning;
|
const updateSpinning: any = this.updateSpinning;
|
||||||
if (updateSpinning && updateSpinning.cancel) {
|
if (updateSpinning && updateSpinning.cancel) {
|
||||||
updateSpinning.cancel();
|
updateSpinning.cancel();
|
||||||
@ -116,6 +120,7 @@ class Spin extends React.Component<SpinProps, SpinState> {
|
|||||||
debouncifyUpdateSpinning = (props?: SpinProps) => {
|
debouncifyUpdateSpinning = (props?: SpinProps) => {
|
||||||
const { delay } = props || this.props;
|
const { delay } = props || this.props;
|
||||||
if (delay) {
|
if (delay) {
|
||||||
|
this.cancelExistingSpin();
|
||||||
this.updateSpinning = debounce(this.originalUpdateSpinning, delay);
|
this.updateSpinning = debounce(this.originalUpdateSpinning, delay);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user