TanStackT
TanStack2w ago
4 replies
popular-magenta

Advice on alternate usage form form composition

I'm writing this because i personally find the useAppForm api not convenient. I do understand the idea to wrap the contexts, the components etc, but it feels:
1. overly verbose for basic usecases
2. still need to add/type lots of things manually, especially with withForm taking its types from defaultValues etc.

Therefore i've crafted something "light" which serves very well my purpose, but i would be very interested in feedbacks (especially from @Luca | LeCarbonator) as for if it's a terrible idea or not.

Basically, my idea is to:

1. create a qualified hook to create a form, which would allow me to grab its type (from ReturnType<typeof myFormHook>)
2. expose the form instance in a context

all this only to be able to do <form.Field in a sub component while keeping the type safety of the form (for the name + data type + single validators).

it looks like this (dont mind the wrappers, they're harmless):
Was this page helpful?