T
TanStack5d ago
equal-aqua

Type safety with prebound Form components

<form.Subscribe
selector={(state) => /* state.values.array[i].attribute */ }
children={(...) => /* Code which uses subField.PreboundField and subField.state*/ }
/>
<form.Subscribe
selector={(state) => /* state.values.array[i].attribute */ }
children={(...) => /* Code which uses subField.PreboundField and subField.state*/ }
/>
I'm trying to extract part of my form into a component, from what I could tell prebound form components would be my best bet of doing this. However, I lose type safety when using useFormContext() when trying to access form data or useFieldContext() Is there a way to maintain type safety in this situation?
Form Composition | TanStack Form React Docs
A common criticism of TanStack Form is its verbosity out-of-the-box. While this can be useful for educational purposes helping enforce understanding our APIs it's not ideal in production use cases. As...
2 Replies
xenial-black
xenial-black5d ago
If you expect not just any form, but a form with a specific shape, you should use withForm
equal-aqua
equal-aquaOP4d ago
Many thanks, as always you're saving my ass lol

Did you find this page helpful?