mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 02:59:04 +08:00
fix #12131. Fix first slash of spin with delay
This commit is contained in:
parent
b1f9f03b3d
commit
2fe119c748
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user