full state management with tanstack form with seperate components
i want to create seperate component and unifed them in form and can i or should use all the states with tanstack form? like is thera a pattern for that? its a very complex form
basically what im trying to achieve is, i want to manage the variations assign accounts every state trough tanstack-form so it can validate with zod


8 Replies
optimistic-gold•2mo ago
well, you have two main patterns you can go for, mostly steered by how submission happens
Variation 1 is that you have segments of fields (like account data), and once all is changed, you save your whole profile which will include that change.
Variation 2 is that you have multiple small forms that each have their own save functionality (so changing profiles, changing data etc.)
robust-apricotOP•2mo ago
can i use external states with tanstack form? @Luca | LeCarbonator
what was i trying to achievin the first place that all components are kinda complex and have their own validation and states
so if i can somehow make it work with tanstack form my life would be much easier
optimistic-gold•2mo ago
you mean like passing state and setState from an external place?
robust-apricotOP•2mo ago
yeah, for example zustand etc.
i would be able to use the state from a different file. and instead of one giant form thing
optimistic-gold•2mo ago
form composition allows you to split files too. As far as zustand goes, I think some users have discussed it on here before, but I don‘t remember if it lead anywhere
robust-apricotOP•2mo ago
also second problem that i have binding the zod schema in different file im havinf type errors from it maybe im doing something wrong but currently experience that i have with tanstack form is like this
optimistic-gold•2mo ago
that sounds like a mismatch between your default values and
z.input<typeof yourSchema>robust-apricotOP•2mo ago
yeah exaclty so zod doesn't accept undefined in schema but stanstack type default says gives you undefined so kinda mismatches yeah