Antd
migration
byCodemod

Antd/Remove Static Method

/icons/calendar.svg

Last update

Jul 24, 2024

Replace message.warn with message.warning. Replace notification.close with notification.destroy.

Example

Before

import { message, notification } from 'antd';
const App = () => {
const [messageApi, contextHolder] = message.useMessage();
const onClick1 = () => {
message.warn();
}
const onClick2 = () => {
messageApi.warn();
};
const [notificationApi] = notification.useNotification();
const onClick3 = () => {
notification.close();
}
const onClick4 = () => {
notificationApi.close();
};
return <>{contextHolder}</>;
};

After

import { message, notification } from 'antd';
const App = () => {
const [messageApi, contextHolder] = message.useMessage();
const onClick1 = () => {
message.warning();
}
const onClick2 = () => {
messageApi.warning();
};
const [notificationApi] = notification.useNotification();
const onClick3 = () => {
notification.destroy();
}
const onClick4 = () => {
notificationApi.destroy();
};
return <>{contextHolder}</>;
};

Build custom codemods

Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community

background illustrationGet Started Now