Basically I move FormField to another component and I need to pass in Form a props, the way I'm currently doing doesn't give auto-complete because of UseFormReturn<any>.
export default function FormComponent() {
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
folderID: 0,
},
})
return (
<Form>
<FolderIdFormField form={form} />
</Form>
}
export function FolderIdFormField({
form
}: {
form: UseFormReturn<any>;
}) {
...
return (
<FormField
control={form.control}
name='folderID'
render={({ field }) => (
...
)}
/>
);
}
export default function FormComponent() {
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
folderID: 0,
},
})
return (
<Form>
<FolderIdFormField form={form} />
</Form>
}
export function FolderIdFormField({
form
}: {
form: UseFormReturn<any>;
}) {
...
return (
<FormField
control={form.control}
name='folderID'
render={({ field }) => (
...
)}
/>
);
}
0 Replies
No replies yetBe the first to reply to this messageJoin