Creating a reusable form component in typescript with function overloading #12471
Unanswered
ben519
asked this question in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Recently struggled to create a re-useable, modular component of form inputs. For example, something like
that I could incorporate into multiple, broader forms. I ended up getting this to work with function overloading.
Thought I'd drop my code here for others (and future me).
In this example,
EmployeeFormData
andEmployerFormData
are hypothetical typescript interfaces used when you declare your form withuseForm()
. For example, something likeI'm very new to Typescript.. Use this at your own risk!
Beta Was this translation helpful? Give feedback.
All reactions