You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -24,6 +25,19 @@ export type UseFieldPropsParams = {
24
25
unsafe__isDisabled?: boolean;
25
26
};
26
27
28
+
constVALUE_PROPERTIES=[
29
+
'value',
30
+
'defaultValue',
31
+
'isSelected',
32
+
'defaultSelected',
33
+
'isIndeterminate',
34
+
'defaultIndeterminate',
35
+
'selectedKey',
36
+
'defaultSelectedKey',
37
+
'selectedKeys',
38
+
'defaultSelectedKeys',
39
+
];
40
+
27
41
exportfunctionuseFieldProps<
28
42
TextendsFieldTypes,
29
43
PropsextendsCubeFieldProps<T>,
@@ -77,7 +91,23 @@ export function useFieldProps<
77
91
),
78
92
);
79
93
80
-
constresult=isOutsideOfForm
94
+
if(props.rules&&!props.name){
95
+
warn(
96
+
`The "rules" prop is not suitable for fields that are not part of a form. Use "name" prop to link the field to a form.`,
97
+
);
98
+
}
99
+
100
+
if(isOutsideOfForm){
101
+
for(constvaluePropNameofVALUE_PROPERTIES){
102
+
if(valuePropNameinprops){
103
+
warn(
104
+
`The "${valuePropName}" property is not suitable for fields that are part of a form. To set default values, please use the "defaultValues" property of the form component instead. To unlink the field from the form, remove the "name" property from the field.`,
105
+
);
106
+
}
107
+
}
108
+
}
109
+
110
+
constresult: Props=isOutsideOfForm
81
111
? props
82
112
: mergeProps(
83
113
props,
@@ -89,6 +119,16 @@ export function useFieldProps<
0 commit comments