feat: Remove unless necessary warning in alert (#47633)

This commit is contained in:
kiner-tang 2024-02-28 17:15:20 +08:00 committed by GitHub
parent 9c1e63dc8d
commit 183746ac3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 0 additions and 19 deletions

View File

@ -42,10 +42,6 @@ export interface AlertProps {
rootClassName?: string;
banner?: boolean;
icon?: React.ReactNode;
/**
* Custom closeIcon
* @deprecated please use `closable.closeIcon` instead.
*/
closeIcon?: React.ReactNode;
action?: React.ReactNode;
onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
@ -131,7 +127,6 @@ const Alert: React.FC<AlertProps> = (props) => {
if (process.env.NODE_ENV !== 'production') {
const warning = devUseWarning('Alert');
warning.deprecated(!closeText, 'closeText', 'closable.closeIcon');
warning.deprecated(!closeIcon, 'closeIcon', 'closable.closeIcon');
}
const ref = React.useRef<HTMLDivElement>(null);

View File

@ -191,20 +191,6 @@ describe('Alert', () => {
expect(container.querySelector('.ant-alert-close-icon')?.textContent).toBe('close');
warnSpy.mockRestore();
});
it('should warning when using closeIcon', () => {
resetWarned();
const warnSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
const { container } = render(<Alert closeIcon="close" />);
expect(warnSpy).toHaveBeenCalledWith(
`Warning: [antd: Alert] \`closeIcon\` is deprecated. Please use \`closable.closeIcon\` instead.`,
);
expect(container.querySelector('.ant-alert-close-icon')?.textContent).toBe('close');
warnSpy.mockRestore();
});
});