How to create a reusable custom Input component with typesafe name prop? #11440
Unanswered
thebishalniroula
asked this question in
Q&A
Replies: 2 comments
-
I just opened a similar discussion before seeing this. I'm in the exact same position at the moment. Following. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I've struggled with this in the past and just had to solve it again so hopefully writing it down I will now remember it. In general you have to pass in
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have been trying to create a custom reusable Input component that accepts a name prop from the parent.
I want to initialize the useForm from the parent component and define all the validation schema in the parent itself.
Now, how do I type the name prop in the Input component such that it somehow infers the type of name from the parent component.
I have managed to achieve this by passing an unused type prop as below, it provides autocomplete to name prop and is typesafe. But this just does not feel right.
And from the parent
Note: Importing the Form Schema Type from the parent is not an option because I want the component to be reusable accross multiple forms.
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions