From 183746ac3fa6b818e560b34abbaea3075e0bb6f3 Mon Sep 17 00:00:00 2001 From: kiner-tang <1127031143@qq.com> Date: Wed, 28 Feb 2024 17:15:20 +0800 Subject: [PATCH] feat: Remove unless necessary warning in alert (#47633) --- components/alert/Alert.tsx | 5 ----- components/alert/__tests__/index.test.tsx | 14 -------------- 2 files changed, 19 deletions(-) diff --git a/components/alert/Alert.tsx b/components/alert/Alert.tsx index 1b190dc7da..c3b5bf4e88 100644 --- a/components/alert/Alert.tsx +++ b/components/alert/Alert.tsx @@ -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; @@ -131,7 +127,6 @@ const Alert: React.FC = (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(null); diff --git a/components/alert/__tests__/index.test.tsx b/components/alert/__tests__/index.test.tsx index 72a29c287c..2c170b49b0 100644 --- a/components/alert/__tests__/index.test.tsx +++ b/components/alert/__tests__/index.test.tsx @@ -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(); - - 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(); }); });