This repository contains a collection of codemod scripts based for use with JSCodeshift that help update antd APIs.
npm install -g jscodeshiftgit clone https://github.com/ant-design/antd-codemod.gitor download a zip file fromhttps://github.com/ant-design/antd-codemod/archive/master.zip- Run
npm installin the antd-codemod directory jscodeshift -t <codemod-script> <path>- Use the
-doption for a dry-run and use-pto print the output for comparison
Replace deprecated getFieldProps with newer getFieldDecorator:
- <Input placeholder="text" {...getFieldProps('userName', { ... })} />
+ {getFieldDecorator('userName', { ... })(
+ <Input placeholder="text" />
+ )}Popover[overlay] is removed, so we need to replace it with Popover[content]:
- <Popover overlay={...} />
+ <Popover content={...} />Update value defaultValue and format of DatePicker TimePicker Calendar MonthPicker(not support RangePicker now):
+ import moment from 'moment';
<DatePicker
- defaultValue="2016-11-24 00:00:00"
+ defaultValue={moment('2016-11-24 00:00:00', 'YYYY-MM-DD HH:mm:ss')}
showTime
- format="yyyy-MM-dd HH:mm:ss"
+ format="YYYY-MM-DD HH:mm:ss"
/>Update GregorianCalendar's APIs to moment's APIs.
function disabledDate(date) {
- console.log(date.getTime());
+ console.log(date.valueOf());
}MIT