@@ -20,13 +20,11 @@ export interface FormProps extends BaseFormProps {
20
20
initialValues ?: Store ;
21
21
form ?: FormInstance ;
22
22
children ?: RenderProps | React . ReactNode ;
23
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
+ component ?: false | string | React . FC < any > | React . ComponentClass < any > ;
23
25
fields ?: FieldData [ ] ;
24
26
name ?: string ;
25
27
validateMessages ?: ValidateMessages ;
26
- __COMPATIBILITY_USAGE_OR_YOU_WILL_BE_FIRED__ ?: {
27
- NOT_CONTAIN_FORM ?: boolean ;
28
- HOOK_MARK : string ;
29
- } ;
30
28
onValuesChange ?: Callbacks [ 'onValuesChange' ] ;
31
29
onFieldsChange ?: Callbacks [ 'onFieldsChange' ] ;
32
30
onFinish ?: ( values : Store ) => void ;
@@ -39,11 +37,11 @@ const Form: React.FunctionComponent<FormProps> = (
39
37
fields,
40
38
form,
41
39
children,
40
+ component : Component = 'form' ,
42
41
validateMessages,
43
42
onValuesChange,
44
43
onFieldsChange,
45
44
onFinish,
46
- __COMPATIBILITY_USAGE_OR_YOU_WILL_BE_FIRED__ ,
47
45
...restProps
48
46
} : FormProps ,
49
47
ref ,
@@ -113,21 +111,18 @@ const Form: React.FunctionComponent<FormProps> = (
113
111
prevFieldsRef . current = fields ;
114
112
} , [ fields , formInstance ] ) ;
115
113
116
- if (
117
- __COMPATIBILITY_USAGE_OR_YOU_WILL_BE_FIRED__ &&
118
- __COMPATIBILITY_USAGE_OR_YOU_WILL_BE_FIRED__ . NOT_CONTAIN_FORM &&
119
- __COMPATIBILITY_USAGE_OR_YOU_WILL_BE_FIRED__ . HOOK_MARK ===
120
- 'asdihasiodhaohdioahfoihsoefhisihifhsiofhiosfd'
121
- ) {
122
- return (
123
- < FieldContext . Provider value = { formInstance as InternalFormInstance } >
124
- { childrenNode }
125
- </ FieldContext . Provider >
126
- ) ;
114
+ const wrapperNode = (
115
+ < FieldContext . Provider value = { formInstance as InternalFormInstance } >
116
+ { childrenNode }
117
+ </ FieldContext . Provider >
118
+ ) ;
119
+
120
+ if ( Component === false ) {
121
+ return wrapperNode ;
127
122
}
128
123
129
124
return (
130
- < form
125
+ < Component
131
126
{ ...restProps }
132
127
onSubmit = { event => {
133
128
event . preventDefault ( ) ;
@@ -144,10 +139,8 @@ const Form: React.FunctionComponent<FormProps> = (
144
139
. catch ( e => e ) ;
145
140
} }
146
141
>
147
- < FieldContext . Provider value = { formInstance as InternalFormInstance } >
148
- { childrenNode }
149
- </ FieldContext . Provider >
150
- </ form >
142
+ { wrapperNode }
143
+ </ Component >
151
144
) ;
152
145
} ;
153
146
0 commit comments