Skip to content

Commit cdf783c

Browse files
committed
docs(arrays): add array key docs
1 parent f9616f9 commit cdf783c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

docs/framework/react/guides/arrays.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ Finally, you can use a subfield like so:
5252
</form.Field>
5353
```
5454

55+
## Why Index as Key?
56+
57+
You may notice that these examples use `key={i}` the array index as the key prop. React's documentation generally advises _against_ using array indices as keys when items can be reordered or deleted. TanStack Form is an exception to this rule. Because field names in TanStack Form arrays are index-based, using the array index as `key` is required, it keeps React component instances, form store state, and field names in sync.
58+
5559
## Full Example
5660

5761
```jsx

0 commit comments

Comments
 (0)