This repository contains a collection of codemod scripts based for use with JSCodeshift that help update antd
APIs.
npm install -g jscodeshift
git clone https://github.com/ant-design/antd-codemod.git
or download a zip file fromhttps://github.com/ant-design/antd-codemod/archive/master.zip
- Run
npm install
in the antd-codemod directory jscodeshift -t <codemod-script> <path>
- Use the
-d
option for a dry-run and use-p
to 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