how to get object props in withForm(with type safetey)
I am trying to split my code.
So I have a product variants array. And each variant contain options array.
So in OptionList component I am trying to get variantField as a props. But it's giving type issue.
How can I overcame it?
Thank You

7 Replies
magic-amber•5mo ago
with the same form options, you should pass all the parameters to access your specific variant. In this case, it sounds like two indeces:
one index determines which variant
another index determines which option
fascinating-indigoOP•5mo ago
actually it's about type issue

fascinating-indigoOP•5mo ago
this is proper type

magic-amber•5mo ago
You're not intended to pass fields around like that. You can read up on why in the Philosophy page.
As for actually implementing this, you have a button that deletes something, yet the affected component is the one above yours. The React way to go about it would be to use an event instead:
Philosophy | TanStack Form Docs
Every well-established project should have a philosophy that guides its development. Without a core philosophy, development can languish in endless decision-making and have weaker APIs as a result. Th...
fascinating-indigoOP•5mo ago
Got it. Thanks for your support. ❤️
exotic-emerald•4mo ago
is
props: {} as OptionListProps, good practice?magic-amber•4mo ago
props yes, defaultValues no