Reusable array component
Hi, I am trying to create reusable array component but it feels like i am doing something wrong. What is idiomatic way to do it?
I am at this so far:
(I get string cannot be assigned to never on
name
property and string cannot be assigned to updaterFn<never,never> in onChange)6 Replies
correct-apricot•3w ago
The form is typed as not having any fields, as this isn't really the intended usage of Form Composition
besides, even if it were typed to have some sort of fields, TS would not be able to infer that
${field.name}[${field.index}]
must existadverse-sapphireOP•3w ago
Is there better way to acomplish this?
correct-apricot•3w ago
Depends. With your current idea, you hide the logic of the fields behind the component, so you lose out on changing them later. Is that a problem, or do you already know what the configuration of the field is in advance?
adverse-sapphireOP•3w ago
I have similar array fields reused multiple times in my designs. So i know configuration and that they are stable. I need to change stuff like label and so but logic stays the same.
correct-apricot•3w ago
withFieldGroup
could be the answer you're looking for. It allows the child fields to use AppField
, which in turn means you can use field components.
Rough draft of what it would look like:
adverse-sapphireOP•3w ago
Thanks i will try this.