mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-25 03:29:59 +08:00
chore: Add warning when use remove function (#20527)
This commit is contained in:
parent
0189ba61bf
commit
e3126ab20d
@ -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.',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -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 };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user