diff --git a/components/spin/__tests__/__snapshots__/index.test.js.snap b/components/spin/__tests__/__snapshots__/index.test.js.snap index 73e2f59bed21..0485c9e09591 100644 --- a/components/spin/__tests__/__snapshots__/index.test.js.snap +++ b/components/spin/__tests__/__snapshots__/index.test.js.snap @@ -1,5 +1,18 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Spin if indicator set null should not be render default indicator 1`] = ` + +
+ +`; + exports[`Spin should render custom indicator when it's set 1`] = `
{ wrapper.setProps({ spinning: true }); expect(wrapper.instance().state.spinning).toBe(true); }); + + it('if indicator set null should not be render default indicator', () => { + const wrapper = mount(); + expect(wrapper).toMatchSnapshot(); + }); }); diff --git a/components/spin/index.tsx b/components/spin/index.tsx index f072491a11bd..3f07daea935f 100644 --- a/components/spin/index.tsx +++ b/components/spin/index.tsx @@ -7,7 +7,7 @@ import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; import { tuple } from '../_util/type'; const SpinSizes = tuple('small', 'default', 'large'); -export type SpinSize = (typeof SpinSizes)[number]; +export type SpinSize = typeof SpinSizes[number]; export type SpinIndicator = React.ReactElement; export interface SpinProps { @@ -33,6 +33,12 @@ let defaultIndicator: React.ReactNode = null; function renderIndicator(prefixCls: string, props: SpinProps): React.ReactNode { const { indicator } = props; const dotClassName = `${prefixCls}-dot`; + + // should not be render default indicator when indicator value is null + if (indicator === null) { + return null; + } + if (React.isValidElement(indicator)) { return React.cloneElement(indicator, { className: classNames(indicator.props.className, dotClassName),