Typed errors for useFieldContext?
I'm following the guide on Form Composition on the official website. I really like the idea of being able to abstract some of these fields into their own components. But I'm trying to render the errors that can come from this field by extracting the field state using useStore.
The issue is that
useStore(field.store, (state) => state.meta.errors) is returning any[]. and checking the documentation a second time along with the types returned via createFormHookContexts it seems as though that's intentional. I found this a bit weird as my experience with you guys is that you're very strict about typing so I figured I must be doing something wrong.
The result is that I have to do stuff like this:
It definitely works but I feel like maybe this should be a field group. That also doesn't feel right though so I'm not sure what to do with this. Any ideas?3 Replies
rival-black•2mo ago
The field context doesn't know about the incoming errors, as they could come from anywhere.
The errors are typed in the callback of
AppField or Field, so if you want to have them pretyped, pass them through props instead
rival-blackOP•2mo ago
OK fair enough. I fiured it was something like tha. Thanks!
rival-black•2mo ago
let me know if other issues come up