TanStackT
TanStack5mo ago
2 replies
dead-brown

Type safety with prebound Form components

<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?
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...
Form Composition | TanStack Form React Docs
Was this page helpful?