@@ -25,6 +25,7 @@ import {
25
25
defaultGetValueFromEvent ,
26
26
getNamePath ,
27
27
getValue ,
28
+ mountNameByPath ,
28
29
} from './utils/valueUtil' ;
29
30
30
31
const EMPTY_ERRORS : any [ ] = [ ] ;
@@ -490,9 +491,16 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
490
491
// Support render props
491
492
if ( typeof children === 'function' ) {
492
493
const meta = this . getMeta ( ) ;
493
-
494
494
return {
495
- ...this . getOnlyChild ( children ( this . getControlled ( ) , meta , this . props . fieldContext ) ) ,
495
+ ...this . getOnlyChild (
496
+ children (
497
+ this . getControlled ( {
498
+ name : mountNameByPath ( this . getNamePath ( ) ) ,
499
+ } ) ,
500
+ meta ,
501
+ this . props . fieldContext ,
502
+ ) ,
503
+ ) ,
496
504
isFunction : true ,
497
505
} ;
498
506
}
@@ -610,9 +618,13 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
610
618
if ( isFunction ) {
611
619
returnChildNode = child ;
612
620
} else if ( React . isValidElement ( child ) ) {
621
+ const theProps = ( child as React . ReactElement ) . props ;
613
622
returnChildNode = React . cloneElement (
614
623
child as React . ReactElement ,
615
- this . getControlled ( ( child as React . ReactElement ) . props ) ,
624
+ this . getControlled ( {
625
+ ...theProps ,
626
+ name : theProps ?. name ?? mountNameByPath ( this . getNamePath ( ) ) ,
627
+ } ) ,
616
628
) ;
617
629
} else {
618
630
warning ( ! child , '`children` of Field is not validate ReactElement.' ) ;
0 commit comments