Skip to content

Commit 5df5ac1

Browse files
committed
fix ts
1 parent 953d5b3 commit 5df5ac1

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/List.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ interface ListProps {
2020
children?: (fields: ListField[], operations: ListOperations) => JSX.Element | React.ReactNode;
2121
}
2222

23-
interface ListRenderProps {
24-
value: StoreValue[];
25-
onChange: (value: StoreValue[]) => void;
26-
}
27-
2823
const List: React.FunctionComponent<ListProps> = ({ name, children }) => {
2924
// User should not pass `children` as other type.
3025
if (typeof children !== 'function') {
@@ -48,20 +43,20 @@ const List: React.FunctionComponent<ListProps> = ({ name, children }) => {
4843
return (
4944
<FieldContext.Provider value={{ ...context, prefixName }}>
5045
<Field name={[]} shouldUpdate={shouldUpdate}>
51-
{({ value = [], onChange }: ListRenderProps) => {
46+
{({ value = [], onChange }) => {
5247
const { getInternalHooks, getFieldValue, setFieldsValue, setFields } = context;
5348

5449
/**
5550
* Always get latest value in case user update fields by `form` api.
5651
*/
5752
const operations: ListOperations = {
5853
add: () => {
59-
const newValue = getFieldValue(prefixName) || [];
54+
const newValue = (getFieldValue(prefixName) || []) as StoreValue[];
6055
onChange([...newValue, undefined]);
6156
},
6257
remove: (index: number) => {
6358
const { getFields } = getInternalHooks(HOOK_MARK);
64-
const newValue = getFieldValue(prefixName) || [];
59+
const newValue = (getFieldValue(prefixName) || []) as StoreValue[];
6560
const namePathList: InternalNamePath[] = newValue.map((__, i) => [
6661
...prefixName,
6762
i,
@@ -91,7 +86,7 @@ const List: React.FunctionComponent<ListProps> = ({ name, children }) => {
9186
};
9287

9388
return children(
94-
value.map(
89+
(value as StoreValue[]).map(
9590
(__, index): ListField => ({
9691
name: index,
9792
key: index,

0 commit comments

Comments
 (0)