11import * as React from 'react' ;
22import warning from '@rc-component/util/lib/warning' ;
3- import type { InternalNamePath , NamePath , StoreValue , ValidatorRule , Meta } from './interface' ;
3+ import type {
4+ InternalNamePath ,
5+ NamePath ,
6+ StoreValue ,
7+ ValidatorRule ,
8+ Meta ,
9+ InternalFormInstance ,
10+ } from './interface' ;
411import FieldContext from './FieldContext' ;
512import Field from './Field' ;
613import { move , getNamePath } from './utils/valueUtil' ;
@@ -40,18 +47,19 @@ function List<Values = any>({
4047} : ListProps < Values > ) {
4148 const context = React . useContext ( FieldContext ) ;
4249 const wrapperListContext = React . useContext ( ListContext ) ;
43- const keyRef = React . useRef ( {
44- keys : [ ] ,
45- id : 0 ,
46- } ) ;
50+ const keyRef = React . useRef ( { keys : [ ] , id : 0 } ) ;
51+
4752 const keyManager = keyRef . current ;
4853
49- const prefixName : InternalNamePath = React . useMemo ( ( ) => {
54+ const prefixName = React . useMemo < InternalNamePath > ( ( ) => {
5055 const parentPrefixName = getNamePath ( context . prefixName ) || [ ] ;
5156 return [ ...parentPrefixName , ...getNamePath ( name ) ] ;
5257 } , [ context . prefixName , name ] ) ;
5358
54- const fieldContext = React . useMemo ( ( ) => ( { ...context , prefixName } ) , [ context , prefixName ] ) ;
59+ const fieldContext = React . useMemo < InternalFormInstance > (
60+ ( ) => ( { ...context , prefixName } ) ,
61+ [ context , prefixName ] ,
62+ ) ;
5563
5664 // List context
5765 const listContext = React . useMemo < ListContextProps > (
@@ -62,7 +70,7 @@ function List<Values = any>({
6270 return [ keyManager . keys [ pathName ] , namePath . slice ( len + 1 ) ] ;
6371 } ,
6472 } ) ,
65- [ prefixName ] ,
73+ [ keyManager , prefixName ] ,
6674 ) ;
6775
6876 // User should not pass `children` as other type.
0 commit comments