Before run codemod scripts, you’d better make sure to commit your local git changes firstly.
# Run directly through npx
npx -p @ant-design/codemod-v5 antd5-codemod src
# Or run directly through pnpm
pnpm --package=@ant-design/codemod-v5 dlx antd5-codemod src
Codemod scripts introduction
v5-removed-component-migration
Replace import for removed component in v5.
Change Comment import from @ant-design/compatible.
Change PageHeader import from @ant-design/pro-layout.
Use BackTop from FloatButton.BackTop.
- import { Avatar, BackTop, Comment, PageHeader } from 'antd';
+ import { Comment } from '@ant-design/compatible';
+ import { PageHeader } from '@ant-design/pro-layout';
+ import { Avatar, FloatButton } from 'antd';
ReactDOM.render( (
<div>
<PageHeader
className="site-page-header"
onBack={() => null}
title="Title"
subTitle="This is a subtitle"
/>
<Comment
actions={actions}
author={<a>Han Solo</a>}
avatar={<Avatar src="https://joeschmoe.io/api/v1/random" alt="Han Solo" />}
content={
<p>
We supply a series of design principles, practical patterns and high quality design
resources (Sketch and Axure), to help people create their product prototypes beautifully
and efficiently.
</p>
}
datetime={
<span title="2016-11-22 11:22:33">8 hours ago</span>
}
/>
- <BackTop />
+ <FloatButton.BackTop />
</div>
);
English | 简体中文
Ant Design v5 Codemod
A collection of codemod scripts that help upgrade antd v5 using jscodeshift and postcss.(Inspired by react-codemod)
Usage
Before run codemod scripts, you’d better make sure to commit your local git changes firstly.
Codemod scripts introduction
v5-removed-component-migrationReplace import for removed component in v5.
Commentimport from@ant-design/compatible.PageHeaderimport from@ant-design/pro-layout.BackTopfromFloatButton.BackTop.v5-props-changed-migrationChange props usage from v4 to v5.
v5-removed-static-method-migrationmessage.warnwithmessage.warning.notification.closewithnotification.destroy.v5-remove-style-importComment out the style file import from antd (in js file).
Remove Antd Lessin less fileComment out the style file import from antd in less file.
Development
License
MIT