Skip to content
Source
Sign inSign up
TanStack/form

[v2] `field.replaceValue` is missing from `form.FieldArray` #2418

ClosedLeCarbonator(GitHub profile, opens in a new tab) opened this issue 1 comment

Discussed in https://github.com/TanStack/form/discussions/2417

Originally posted by **Jack-Dark** October 3, 2026 `replaceValue` used to be available from `` in v1, but it is not available in `` in v2, forcing you to use `field.insertValue`, then `field.removeValue` to get the same functionality. This is an unneeded regression from v1.

Example:

// v1 example
< form.AppField mode="array" name="arrayFieldName">
  {({ replaceValue }) => {
    return (
      <div onClick={() => {
        replaceValue(...);
      }}>
        // ...
      </div>
    );
  }}
</form.ArrayField>


// v2 closest solution
<form.ArrayField name="arrayFieldName">
  {({ insertValue, removeValue }) => {
    const replaceValue = (index, data) => {
      removeValue(index);
      insertValue(index, data);
    }

    return (
      <div onClick={() => {
        replaceValue(...);
      }}>
        // ...
      </div>
    );
  }}
</form.ArrayField>
```</div>
  1. LeCarbonator(GitHub profile, opens in a new tab) added labelstype: bug

  2. LeCarbonator(GitHub profile, opens in a new tab) added labelsscope: core

  3. LeCarbonator(GitHub profile, opens in a new tab) added labelsarea: runtime

  4. LeCarbonator(GitHub profile, opens in a new tab)commented

    Now that I'm thinking about it. What's the user-side difference between these?

    form.replaceFieldValue('users', 0, newUser)
    
    form.setFieldValue('users[0]', newUser)

    I'd say these are equivalent, right?

    Nevermind. field.replaceValue is not the same semantics.

Sign in to join this conversation.