import * as React from 'react'; import { List } from 'rc-field-form'; import warning from '../_util/warning'; interface FieldData { name: number; key: number; fieldKey: number; } interface Operation { add: () => void; remove: (index: number) => void; } interface FormListProps { name: string | number | (string | number)[]; children: (fields: FieldData[], operation: Operation) => React.ReactNode; } const FormList: React.FC = ({ children, ...props }) => { warning(!!props.name, 'Form.List', 'Miss `name` prop.'); return ( {(fields, operation) => { return children(fields.map(field => ({ ...field, fieldKey: field.key })), operation); }} ); }; export default FormList;