fix #12131. Fix first slash of spin with delay

This commit is contained in:
zombiej 2018-09-08 22:43:39 +08:00
parent b1f9f03b3d
commit 2fe119c748

View File

@ -52,6 +52,10 @@ function renderIndicator(props: SpinProps): React.ReactNode {
);
}
function shouldDelay(spinning?: boolean, delay?: number): boolean {
return !!spinning && !!delay && !isNaN(Number(delay));
}
class Spin extends React.Component<SpinProps, SpinState> {
static defaultProps = {
prefixCls: 'ant-spin',
@ -78,9 +82,10 @@ class Spin extends React.Component<SpinProps, SpinState> {
constructor(props: SpinProps) {
super(props);
const spinning = props.spinning;
const { spinning, delay } = props;
this.state = {
spinning,
spinning: !shouldDelay(spinning, delay),
};
}
@ -90,8 +95,7 @@ class Spin extends React.Component<SpinProps, SpinState> {
componentDidMount() {
const { spinning, delay } = this.props;
if (spinning && delay && !isNaN(Number(delay))) {
this.setState({ spinning: false });
if (shouldDelay(spinning, delay)) {
this.delayTimeout = window.setTimeout(() => this.setState({ spinning }), delay);
}
}