Skip to content

Commit 452d666

Browse files
committed
docs: clarify keyed each blocks
1 parent 0e22b54 commit 452d666

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

documentation/docs/03-template-syntax/03-each.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ An each block can also specify an _index_, equivalent to the second argument in
4343
{#each expression as name, index (key)}...{/each}
4444
```
4545

46-
If a _key_ expression is provided — which must uniquely identify each list item — Svelte will use it to diff the list when data changes, rather than adding or removing items at the end. The key can be any object, but strings and numbers are recommended since they allow identity to persist when the objects themselves change.
46+
If a _key_ expression is provided — which must uniquely identify each list item — Svelte will use it to intelligently update the list when data changes by inserting, moving and deleting items, rather than adding or removing items at the end and updating the state in the middle.
47+
48+
The key can be any object, but strings and numbers are recommended since they allow identity to persist when the objects themselves change.
4749

4850
```svelte
4951
{#each items as item (item.id)}

0 commit comments

Comments
 (0)