From 5df766fb5b2cce9f02c3b3d09d39bf5b5a844c74 Mon Sep 17 00:00:00 2001 From: wadezhan Date: Tue, 16 Jul 2019 22:06:58 +0800 Subject: [PATCH] feat(Empty): description prop support undefined/null value to remove description node --- components/empty/__tests__/index.test.js | 2 +- components/empty/demo/description.md | 2 +- components/empty/index.en-US.md | 2 +- components/empty/index.tsx | 4 ++-- components/empty/index.zh-CN.md | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/empty/__tests__/index.test.js b/components/empty/__tests__/index.test.js index a883a7cd20..cf5a06e050 100644 --- a/components/empty/__tests__/index.test.js +++ b/components/empty/__tests__/index.test.js @@ -9,7 +9,7 @@ describe('Empty', () => { }); it('description can be false', () => { - const wrapper = mount(); + const wrapper = mount(); expect(wrapper.find('.ant-empty-description').length).toBe(0); }); }); diff --git a/components/empty/demo/description.md b/components/empty/demo/description.md index 17ee7da07f..4a4e467282 100644 --- a/components/empty/demo/description.md +++ b/components/empty/demo/description.md @@ -16,5 +16,5 @@ Simplest Usage with no description. ```jsx import { Empty } from 'antd'; -ReactDOM.render(, mountNode); +ReactDOM.render(, mountNode); ``` diff --git a/components/empty/index.en-US.md b/components/empty/index.en-US.md index 6061cc0171..1ed5f68be6 100644 --- a/components/empty/index.en-US.md +++ b/components/empty/index.en-US.md @@ -22,7 +22,7 @@ Empty state placeholder. | Property | Description | Type | Default | Version | | --- | --- | --- | --- | --- | -| description | Customize description | string \| ReactNode \| boolean | - | 3.12.0 | +| description | Customize description | string \| ReactNode | - | 3.12.0 | | imageStyle | style of image | CSSProperties | - | 3.16.0 | | image | Customize image. Will tread as image url when string provided. | string \| ReactNode | `Empty.PRESENTED_IMAGE_DEFAULT` | 3.12.0 | diff --git a/components/empty/index.tsx b/components/empty/index.tsx index aa259b1772..fb53f0ac15 100644 --- a/components/empty/index.tsx +++ b/components/empty/index.tsx @@ -18,7 +18,7 @@ export interface EmptyProps { */ imageStyle?: React.CSSProperties; image?: React.ReactNode; - description?: React.ReactNode | boolean; + description?: React.ReactNode; children?: React.ReactNode; } @@ -39,7 +39,7 @@ const OriginEmpty: React.SFC = (props: EmptyProps) => ( {(locale: TransferLocale) => { const prefixCls = getPrefixCls('empty', customizePrefixCls); - const des = typeof description === 'boolean' ? description : (description || locale.description); + const des = description == null ? description : (description || locale.description); const alt = typeof des === 'string' ? des : 'empty'; let imageNode: React.ReactNode = null; diff --git a/components/empty/index.zh-CN.md b/components/empty/index.zh-CN.md index b8fc93e614..b7c31b46b4 100644 --- a/components/empty/index.zh-CN.md +++ b/components/empty/index.zh-CN.md @@ -23,7 +23,7 @@ cols: 1 | 参数 | 说明 | 类型 | 默认值 | 版本 | | --- | --- | --- | --- | --- | -| description | 自定义描述内容 | string \| ReactNode \| boolean | - | 3.12.0 | +| description | 自定义描述内容 | string \| ReactNode | - | 3.12.0 | | imageStyle | 图片样式 | CSSProperties | - | 3.16.0 | | image | 设置显示图片,为 string 时表示自定义图片地址。 | string \| ReactNode | `Empty.PRESENTED_IMAGE_DEFAULT` | 3.12.0 |