chore: Add warning when use remove function (#20527)

This commit is contained in:
二货机器人 2019-12-30 12:13:58 +08:00 committed by GitHub
parent 0189ba61bf
commit e3126ab20d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -244,4 +244,11 @@ describe('Form', () => {
expect(wrapper.find('.ant-form-item-with-help').length).toBeTruthy();
});
it('warning when use v3 function', () => {
Form.create();
expect(errorSpy).toHaveBeenCalledWith(
'Warning: [antd: Form] antd v4 removed `Form.create`. Please remove or use `@ant-design/compatible` instead.',
);
});
});

View File

@ -2,6 +2,7 @@ import InternalForm, { useForm, FormInstance } from './Form';
import Item from './FormItem';
import List from './FormList';
import { FormProvider } from './context';
import warning from '../_util/warning';
type InternalForm = typeof InternalForm;
interface Form extends InternalForm {
@ -9,6 +10,9 @@ interface Form extends InternalForm {
Item: typeof Item;
List: typeof List;
Provider: typeof FormProvider;
/** @deprecated Only for warning usage. Do not use. */
create: () => void;
}
const Form: Form = InternalForm as Form;
@ -17,6 +21,13 @@ Form.Item = Item;
Form.List = List;
Form.useForm = useForm;
Form.Provider = FormProvider;
Form.create = () => {
warning(
false,
'Form',
'antd v4 removed `Form.create`. Please remove or use `@ant-design/compatible` instead.',
);
};
export { FormInstance };