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]);
9999If you use destructuring with a ` $derived ` declaration, the resulting variables will all be reactive — this...
100100
101101``` js
102+ function stuff () { return { a: 1 , b: 2 , c: 3 } }
103+ // ---cut---
102104let { a, b, c } = $derived (stuff ());
103105```
104106
105107...is roughly equivalent to this:
106108
107109``` js
110+ function stuff () { return { a: 1 , b: 2 , c: 3 } }
111+ // ---cut---
108112let _stuff = $derived (stuff ());
109113let a = $derived (_stuff .a );
110114let b = $derived (_stuff .b );
Original file line number Diff line number Diff line change @@ -109,10 +109,10 @@ $effect(() => {
109109The same applies to array mutations, since these both read and write to the array:
110110
111111``` js
112- let array = $state ([]);
112+ let array = $state ([' hello ' ]);
113113
114114$effect (() => {
115- array .push (' hello ' );
115+ array .push (' goodbye ' );
116116});
117117```
118118
Original file line number Diff line number Diff line change @@ -79,10 +79,10 @@ $effect(() => {
7979The same applies to array mutations, since these both read and write to the array:
8080
8181``` js
82- let array = $state ([]);
82+ let array = $state ([' hello ' ]);
8383
8484$effect (() => {
85- array .push (' hello ' );
85+ array .push (' goodbye ' );
8686});
8787```
8888
You can’t perform that action at this time.
0 commit comments