【发布时间】:2021-07-21 03:04:21
【问题描述】:
我的参数是一个对象数组。我尝试实现它,但出现错误。
参数 'option' 隐含一个 'any' type.ts(7006)
我不知道为什么。感谢您的帮助。
const options = [
{label: 'one', name: 'one'},
{label: 'two', name: 'two'},
]
<Checkbox options={options} />
import React from 'react'
import {Checkbox as Cb} from '@material-ui/core'
import {Field, FieldAttributes, useField} from 'formik'
interface CheckboxRecord {
label: string
name: string
}
interface Props {
options: CheckboxRecord[]
}
const Checkbox: React.FC<Props> = options => {
return options.map(option => <Field name={option.name} as={Cb} />)
}
export default Checkbox
【问题讨论】:
标签: reactjs typescript create-react-app