TanStackT
TanStack2mo ago
6 replies
sacred-rose

Inheriting registered fields + form components

I've got an internal component library that I would like to provide a base of the most common components needed for a form; e.g. TextField, SelectField, DateField, etc. I was initially thinking to register those components and have the consuming app inherit them while also being able to create their own fields that aren't covered within that set and register as well. A common use case in the past would be async fields that fetch information specific to that application but maybe it's as simple as just extracting that data layer from the presentational layer. Screenshots linked showcase this scenario where common components are provided via the component library and the following createFormHook build upon those with an app specific ContactSelectField.

I couldn't find any information or examples around this sort of "inheritance of registered components". Maybe that's due to this approach and the community as a whole not seeing a reason to do something like this. I also couldn't find anything about the fieldContext and formContext options in createFormHook. Is there a reason to ever override these options?

Would love to hear how y'all are managing any sort of unique field/form components with Tanstack Form, thanks!
image.png
image.png
Was this page helpful?