Skip to content

Commit c7f12f4

Browse files
committed
rename
1 parent 60aa4e2 commit c7f12f4

File tree

1 file changed

+11
-11
lines changed
  • sites/svelte-5-preview/src/routes/docs/content/01-api

1 file changed

+11
-11
lines changed

sites/svelte-5-preview/src/routes/docs/content/01-api/02-runes.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -254,30 +254,30 @@ An effect only reruns when the object it reads changes, not when a property insi
254254

255255
```svelte
256256
<script>
257-
let a = $state({ value: 0 });
258-
let b = $derived({ value: a.value * 2 });
257+
let state = $state({ value: 0 });
258+
let derived = $derived({ value: state.value * 2 });
259259
260-
// this will run once, because `a` is never reassigned (only mutated)
260+
// this will run once, because `state` is never reassigned (only mutated)
261261
$effect(() => {
262-
a;
262+
state;
263263
});
264264
265-
// this will run whenever `a.value` changes...
265+
// this will run whenever `state.value` changes...
266266
$effect(() => {
267-
a.value;
267+
state.value;
268268
});
269269
270-
// ...and so will this, because `b` is a new object each time
270+
// ...and so will this, because `derived` is a new object each time
271271
$effect(() => {
272-
b;
272+
derived;
273273
});
274274
</script>
275275
276-
<button onclick={() => (a.value += 1)}>
277-
{a.value}
276+
<button onclick={() => (state.value += 1)}>
277+
{state.value}
278278
</button>
279279
280-
<p>{a.value} doubled is {b.value}</p>
280+
<p>{state.value} doubled is {derived.value}</p>
281281
```
282282

283283
You can return a function from `$effect`, which will run immediately before the effect re-runs, and before it is destroyed ([demo](/#H4sIAAAAAAAAE42SzW6DMBCEX2Vl5RDaVCQ9JoDUY--9lUox9lKsGBvZC1GEePcaKPnpqSe86_m0M2t6ViqNnu0_e2Z4jWzP3pqGbRhdmrHwHWrCUHvbOjF2Ei-caijLTU4aCYRtDUEKK0-ccL2NDstNrbRWHoU10t8Eu-121gTVCssSBa3XEaQZ9GMrpziGj0p5OAccCgSHwmEgJZwrNNihg6MyhK7j-gii4uYb_YyGUZ5guQwzPdL7b_U4ZNSOvp9T2B3m1rB5cLx4zMkhtc7AHz7YVCVwEFzrgosTBMuNs52SKDegaPbvWnMH8AhUXaNUIY6-hHCldQhUIcyLCFlfAuHvkCKaYk8iYevGGgy2wyyJnpy9oLwG0sjdNe2yhGhJN32HsUzi2xOapNpl_bSLIYnDeeoVLZE1YI3QSpzSfo7-8J5PKbwOmdf2jC6JZyD7HxpPaMk93aHhF6utVKVCyfbkWhy-hh9Z3o_2nQIAAA==)).

0 commit comments

Comments
 (0)