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
like-gold•3mo 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 existfirm-tanOP•3mo ago
Is there better way to acomplish this?
like-gold•3mo 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?
firm-tanOP•3mo 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.
like-gold•3mo 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:
firm-tanOP•3mo ago
Thanks i will try this.