feat(Empty): description prop support false value to remove description node

This commit is contained in:
wadezhan 2019-07-16 22:32:36 +08:00
parent 9d437d39f9
commit fab98738f4
3 changed files with 4 additions and 4 deletions

View File

@ -8,8 +8,8 @@ describe('Empty', () => {
expect(wrapper.find('.ant-empty-image').props().style.height).toBe(20);
});
it('description can be undefined or null', () => {
const wrapper = mount(<Empty description={undefined} />);
it('description can be false', () => {
const wrapper = mount(<Empty description={false} />);
expect(wrapper.find('.ant-empty-description').length).toBe(0);
});
});

View File

@ -16,5 +16,5 @@ Simplest Usage with no description.
```jsx
import { Empty } from 'antd';
ReactDOM.render(<Empty description={undefined} />, mountNode);
ReactDOM.render(<Empty description={false} />, mountNode);
```

View File

@ -39,7 +39,7 @@ const OriginEmpty: React.SFC<EmptyProps> = (props: EmptyProps) => (
<LocaleReceiver componentName="Empty">
{(locale: TransferLocale) => {
const prefixCls = getPrefixCls('empty', customizePrefixCls);
const des = description == null ? description : (description || locale.description);
const des = typeof description !== 'undefined' ? description : (description || locale.description);
const alt = typeof des === 'string' ? des : 'empty';
let imageNode: React.ReactNode = null;