Skip to content
Source
Sign inSign up
TanStack/form

Add docs and tests for Field Arrays #492

Send to my agent
Closedcrutchcorn(GitHub profile, opens in a new tab) opened this issue 5 comments

Right now, we do support Field Arrays, but their usage is not clear and I have low confidence as a maintainer that we won't break them in the future. Let's update docs and tests for field arrays so that we're able to ship this more confidently.

  1. crutchcorn(GitHub profile, opens in a new tab) added labelstype: enhancement

  2. crutchcorn(GitHub profile, opens in a new tab) added labelsgood first issue

  3. I just tested this in my prototype. How is the API meant to work? I just iterated over the array and built the field name with the index aka

    { name: `employees[${index}].color` }

    This seems to work fine, but DeepKeys does not support it. Is this how you envision the API for FieldArrays though, @crutchcorn?

    Btw my updated prototype is here: https://github.com/Christian24/tanstack-form-lit-prototype/tree/arrays

  4. Upon further investigation it seems correct names look as follows:

    { name: `employees.${index}.color` }

    This works and types also work for this.

  5. Interestingly, there seems to be some documentation on the website already: https://tanstack.com/form/latest/docs/guides/basic-concepts#array-fields

    I did do a quick find usages on index though and Webstorm said it was used nowhere. So, I have no idea if these examples are correct.

  6. There are also already tests present, so maybe this can be closed @crutchcorn

  7. Yea this deffo can be closed, my bad

Sign in to join this conversation.