File tree Expand file tree Collapse file tree 3 files changed +8
-4
lines changed
packages/svelte/messages/client-errors Expand file tree Collapse file tree 3 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -99,12 +99,16 @@ let selected = $derived(items[index]);
99
99
If you use destructuring with a ` $derived ` declaration, the resulting variables will all be reactive — this...
100
100
101
101
``` js
102
+ function stuff () { return { a: 1 , b: 2 , c: 3 } }
103
+ // ---cut---
102
104
let { a, b, c } = $derived (stuff ());
103
105
```
104
106
105
107
...is roughly equivalent to this:
106
108
107
109
``` js
110
+ function stuff () { return { a: 1 , b: 2 , c: 3 } }
111
+ // ---cut---
108
112
let _stuff = $derived (stuff ());
109
113
let a = $derived (_stuff .a );
110
114
let b = $derived (_stuff .b );
Original file line number Diff line number Diff line change @@ -109,10 +109,10 @@ $effect(() => {
109
109
The same applies to array mutations, since these both read and write to the array:
110
110
111
111
``` js
112
- let array = $state ([]);
112
+ let array = $state ([' hello ' ]);
113
113
114
114
$effect (() => {
115
- array .push (' hello ' );
115
+ array .push (' goodbye ' );
116
116
});
117
117
```
118
118
Original file line number Diff line number Diff line change @@ -79,10 +79,10 @@ $effect(() => {
79
79
The same applies to array mutations, since these both read and write to the array:
80
80
81
81
``` js
82
- let array = $state ([]);
82
+ let array = $state ([' hello ' ]);
83
83
84
84
$effect (() => {
85
- array .push (' hello ' );
85
+ array .push (' goodbye ' );
86
86
});
87
87
```
88
88
You can’t perform that action at this time.
0 commit comments