@@ -20,11 +20,6 @@ interface ListProps {
20
20
children ?: ( fields : ListField [ ] , operations : ListOperations ) => JSX . Element | React . ReactNode ;
21
21
}
22
22
23
- interface ListRenderProps {
24
- value : StoreValue [ ] ;
25
- onChange : ( value : StoreValue [ ] ) => void ;
26
- }
27
-
28
23
const List : React . FunctionComponent < ListProps > = ( { name, children } ) => {
29
24
// User should not pass `children` as other type.
30
25
if ( typeof children !== 'function' ) {
@@ -48,20 +43,20 @@ const List: React.FunctionComponent<ListProps> = ({ name, children }) => {
48
43
return (
49
44
< FieldContext . Provider value = { { ...context , prefixName } } >
50
45
< Field name = { [ ] } shouldUpdate = { shouldUpdate } >
51
- { ( { value = [ ] , onChange } : ListRenderProps ) => {
46
+ { ( { value = [ ] , onChange } ) => {
52
47
const { getInternalHooks, getFieldValue, setFieldsValue, setFields } = context ;
53
48
54
49
/**
55
50
* Always get latest value in case user update fields by `form` api.
56
51
*/
57
52
const operations : ListOperations = {
58
53
add : ( ) => {
59
- const newValue = getFieldValue ( prefixName ) || [ ] ;
54
+ const newValue = ( getFieldValue ( prefixName ) || [ ] ) as StoreValue [ ] ;
60
55
onChange ( [ ...newValue , undefined ] ) ;
61
56
} ,
62
57
remove : ( index : number ) => {
63
58
const { getFields } = getInternalHooks ( HOOK_MARK ) ;
64
- const newValue = getFieldValue ( prefixName ) || [ ] ;
59
+ const newValue = ( getFieldValue ( prefixName ) || [ ] ) as StoreValue [ ] ;
65
60
const namePathList : InternalNamePath [ ] = newValue . map ( ( __ , i ) => [
66
61
...prefixName ,
67
62
i ,
@@ -91,7 +86,7 @@ const List: React.FunctionComponent<ListProps> = ({ name, children }) => {
91
86
} ;
92
87
93
88
return children (
94
- value . map (
89
+ ( value as StoreValue [ ] ) . map (
95
90
( __ , index ) : ListField => ( {
96
91
name : index ,
97
92
key : index ,
0 commit comments