Typescript: how to create a sharable piece of form accepting a hookForm as prop #9677
Unanswered
johnyvelho
asked this question in
General
Replies: 0 comments
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.
-
Hey folks! So I have been trying to correct type a component which is a piece of a form (for reuse).
This is what it looks like now:
Types are working fine here in this component. The problem is where I am using it:
I got the following type error on AddressForm:
The error is because I have the extra properties (political_exposure: true, criminal_record: true). I couldn't find a way to make the UseFormReturn accepts extra properties. eg [x: string]: any, didn't help.
For now I endup using the component like this:
<AddressForm hookForm={hookForm as any} />
which is bad, but I couldn't type it correctly.
How could I solve it?
Am I thinking in the wrong way? is there a better way to do something like this?
Thank you <3
Beta Was this translation helpful? Give feedback.
All reactions