array with form composition
How can I use https://tanstack.com/form/latest/docs/framework/react/guides/arrays arrays with form composition. There are no examples of it and I cant type the useFormContext hook to make it work
Arrays | TanStack Form React Docs
TanStack Form supports arrays as values in a form, including sub-object values inside of an array. Basic Usage To use an array, you can use field.state.value on an array value: jsx function App() { co...
4 Replies
correct-apricotOP•6mo ago
this is not working as field.state.value is of type unknown
conscious-sapphire•6mo ago
I don't think useFormContext() contains the full form type, which is why they created the withForm() hoc.
rival-black•6mo ago
useFormContext is really not meant to be used like this. I'd avoid that entirely and use either withForm. Or this pattern:
https://discord.com/channels/719702312431386674/1344358153759756328/1350936904568144043
https://discord.com/channels/719702312431386674/1344358153759756328/1350936904568144043
conscious-sapphire•6mo ago
Holy crap that works!! I saw that comment a couple times but couldn't wrap my head around it. I think I finally understand how to make custom hooks in react.