Replies: 1 comment 2 replies
-
I'd rather not pass the form to the reusable field component, it helps simplify the types and improves component reusability, for example: <FormField
control={form.control}
name={props.name}
render={({ field }) => (
<FormItem>
<FormLabel>{props.label}</FormLabel>
<FormControl>
<SomeCombobox
values={field.value}
onChange={values => form.setValue(props.name, values, {/* other options */ })}
/>
</FormControl>
{props.description && <FormDescription>{props.description}</FormDescription>}
<FormMessage />
</FormItem>
)}
/> |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
After overcoming challenges in defining TypeScript types for a reusable form field, I've managed to arrive at the following type definition. However, I'm curious if there's a more efficient or improved way to handle the typing for form fields. The current implementation is provided below. Can anyone suggest enhancements or a better approach to type these form fields?" For example,
form.setValue(props.name, item.value as any);
still not seems perfect.Usage:
Beta Was this translation helpful? Give feedback.
All reactions