diff --git a/sites/svelte-5-preview/src/routes/docs/content/01-api/02-runes.md b/sites/svelte-5-preview/src/routes/docs/content/01-api/02-runes.md index 850daabb45..0bcccda50e 100644 --- a/sites/svelte-5-preview/src/routes/docs/content/01-api/02-runes.md +++ b/sites/svelte-5-preview/src/routes/docs/content/01-api/02-runes.md @@ -270,14 +270,18 @@ You can return a function from `$effect`, which will run immediately before the If you update `$state` inside an `$effect`, you most likely want to use `$derived` instead. ```svelte + + + + ``` @@ -285,8 +289,8 @@ If you update `$state` inside an `$effect`, you most likely want to use `$derive This also applies to more complex calculations that require more than a simple expression and write to more than one variable. In these cases, you can use `$derived.by`. ```svelte + + + + ``` -When reacting to a state change and writing to a different state as a result, think about if it's possible to model the code through event handling instead. +When reacting to a state change and writing to a different state as a result, think about if it's possible to use callback props instead. ```svelte @@ -337,7 +344,7 @@ If you want to have something update from above but also modify it from below (i ```svelte - + ``` If you absolutely have to update `$state` within an effect and run into an infinite loop because you read and write to the same `$state`, use [untrack](functions#untrack).