Skip to content

Commit 36bb9a1

Browse files
docs: add example of multiple values in a key block
1 parent 6eb720a commit 36bb9a1

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

  • documentation/docs/03-template-syntax

documentation/docs/03-template-syntax/04-key.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,19 @@ It's also useful if you want a transition to play whenever a value changes:
2323
<div transition:fade>{value}</div>
2424
{/key}
2525
```
26+
27+
To recreate the contents when any of several reactive values changes, use an inline array or object:
28+
29+
```svelte
30+
{#key [key1, key2]}
31+
<Component />
32+
{/key}
33+
```
34+
35+
```svelte
36+
{#key { key1, key2 }}
37+
<Component />
38+
{/key}
39+
```
40+
41+
Each evaluation creates a new array or object. In runes mode, these are compared by reference rather than by their contents: using an existing object as the key only recreates the contents when its reference changes, not when its properties change.

0 commit comments

Comments
 (0)