@@ -36,7 +36,10 @@ export interface FieldProps {
36
36
| React . ReactElement
37
37
| ( ( control : ChildProps , meta : Meta , form : FormInstance ) => React . ReactNode ) ;
38
38
rules ?: Rule [ ] ;
39
- /** Set up `dependencies` field. When dependencies field update and current field is touched, will trigger validate rules. */
39
+ /**
40
+ * Set up `dependencies` field.
41
+ * When dependencies field update and current field is touched, will trigger validate rules and render.
42
+ */
40
43
dependencies ?: NamePath [ ] ;
41
44
trigger ?: string ;
42
45
validateTrigger ?: string | string [ ] ;
@@ -123,7 +126,7 @@ class Field extends React.Component<FieldProps, FieldState> implements FieldEnti
123
126
namePathList : InternalNamePath [ ] | null ,
124
127
info : NotifyInfo ,
125
128
) => {
126
- const { shouldUpdate } = this . props ;
129
+ const { shouldUpdate, dependencies = [ ] } = this . props ;
127
130
const { getFieldsValue, getFieldError } : FormInstance = this . context ;
128
131
const values = getFieldsValue ( ) ;
129
132
const namePath = this . getNamePath ( ) ;
@@ -169,11 +172,15 @@ class Field extends React.Component<FieldProps, FieldState> implements FieldEnti
169
172
default :
170
173
/**
171
174
* - If `namePath` exists in `namePathList`, means it's related value and should update.
175
+ * - If `dependencies` exists in `namePathList`, means upstream trigger update.
172
176
* - If `shouldUpdate` provided, use customize logic to update the field
173
177
* - else to check if value changed
174
178
*/
175
179
if (
176
180
( namePathList && containsNamePath ( namePathList , namePath ) ) ||
181
+ dependencies . some ( dependency =>
182
+ containsNamePath ( namePathList , getNamePath ( dependency ) ) ,
183
+ ) ||
177
184
( shouldUpdate ? shouldUpdate ( prevStore , values , info ) : prevValue !== curValue )
178
185
) {
179
186
this . forceUpdate ( ) ;
@@ -327,7 +334,8 @@ class Field extends React.Component<FieldProps, FieldState> implements FieldEnti
327
334
328
335
const { child, isFunction } = this . getOnlyChild ( children ) ;
329
336
if ( ! child ) {
330
- return children ;
337
+ // Return origin `children` if is not a function
338
+ return isFunction ? child : children ;
331
339
}
332
340
333
341
// Not need to `cloneElement` since user can handle this in render function self
0 commit comments