我在函数中遇到 TypeScript 错误handleSubmit。
handleSubmit通过以下方式检索功能useForm:const {handleSubmit, control, watch, reset} = useForm()
Run Code Online (Sandbox Code Playgroud)
const submit = (data: { file: File, crop: Area }) => {
onSubmit(data.file, data.crop) // onSubmit is passed from parent component
}
Run Code Online (Sandbox Code Playgroud)
handleSubmit组件的onSubmitpropForm<Form onSubmit={handleSubmit(submit)}>
// registering form fields here
</Form>
Run Code Online (Sandbox Code Playgroud)
Argument of type '(data: { file: File; crop: Area;}) => void' is not assignable to parameter of type 'SubmitHandler<FieldValues>'.
[1] Types of parameters …Run Code Online (Sandbox Code Playgroud)