From f9c2310424c51c549ddbea38d854604130f7b950 Mon Sep 17 00:00:00 2001 From: zombiej Date: Tue, 9 Oct 2018 00:02:03 +0800 Subject: [PATCH] fix #12539. delay also double confirm spin status. --- components/spin/index.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/components/spin/index.tsx b/components/spin/index.tsx index 9a0e4cc655..ee00f28eeb 100644 --- a/components/spin/index.tsx +++ b/components/spin/index.tsx @@ -96,7 +96,7 @@ class Spin extends React.Component { componentDidMount() { const { spinning, delay } = this.props; if (shouldDelay(spinning, delay)) { - this.delayTimeout = window.setTimeout(() => this.setState({ spinning }), delay); + this.delayTimeout = window.setTimeout(this.delayUpdateSpinning, delay); } } @@ -126,17 +126,24 @@ class Spin extends React.Component { clearTimeout(this.delayTimeout); } } else { - if (spinning && delay && !isNaN(Number(delay))) { + if (shouldDelay(spinning, delay)) { if (this.delayTimeout) { clearTimeout(this.delayTimeout); } - this.delayTimeout = window.setTimeout(() => this.setState({ spinning }), delay); + this.delayTimeout = window.setTimeout(this.delayUpdateSpinning, delay); } else { this.setState({ spinning }); } } } + delayUpdateSpinning = () => { + const { spinning } = this.props; + if (this.state.spinning !== spinning) { + this.setState({ spinning }); + } + }; + render() { const { className, size, prefixCls, tip, wrapperClassName, ...restProps } = this.props; const { spinning } = this.state;