mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 09:26:06 +08:00
parent
d5e3f1e6de
commit
07462491ab
@ -67,4 +67,11 @@ describe('Result', () => {
|
||||
|
||||
warnSpy.mockRestore();
|
||||
});
|
||||
|
||||
it('should hide icon by setting icon to false or null', () => {
|
||||
const { container } = render(<Result title="404" icon={null} />);
|
||||
expect(container.querySelectorAll('.ant-result-icon')).toHaveLength(0);
|
||||
const { container: container2 } = render(<Result title="404" icon={false} />);
|
||||
expect(container2.querySelectorAll('.ant-result-icon')).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
@ -73,10 +73,15 @@ const Icon: React.FC<IconProps> = ({ prefixCls, icon, status }) => {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const iconNode = React.createElement(
|
||||
IconMap[status as Exclude<ResultStatusType, ExceptionStatusType>],
|
||||
);
|
||||
|
||||
if (icon === null || icon === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <div className={className}>{icon || iconNode}</div>;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user