Skip to content

Async initial array values are not set when form.Field is conditionally rendered #2201

@eTallang

Description

@eTallang

Describe the bug

Until version 1.31.0, it's been possible to set async initial values that are in the form of an array, where the form.Field that displays the array is conditionally rendered. In version 1.33.0, this does not seem to work anymore (it was broken from version 1.32.0). This bug is pretty similar to the issue I reported a couple of weeks ago, where the difference is that I now conditionally render the form.Field that displays the array. The use case for this, is showing a loading UI while the async data is fetched. It was concluded in my previous issue that it was a regression from #2172, so I assume the same goes for this new issue.

Your minimal, reproducible example

https://stackblitz.com/edit/tanstack-form-ehnyffpx?file=src%2Findex.tsx

Steps to reproduce

  1. Open the StackBlitz
  2. Notice that no person is displayed after 3 seconds, when the async state is updated and the loading UI disappears
  3. You may click the "Add person"-button to notice that there suddenly is 2 people in the list

Expected behavior

I would expect the form.Field to render the array when the async data is resolved and the form.Field is displayed.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome

TanStack Form adapter

react-form

TanStack Form version

1.33.0 (from 1.32.0)

TypeScript version

6.0.3

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions