Professional Documents
Culture Documents
Introducing Runes
Introducing Runes
Joinyour
determined when Svelte compiles us atcomponent:
Svelte Summit on Nov 11
<script>
export let width;
export let height;
This works well... until it doesn't. Suppose we refactored the code above:
Because the $: area = ... declaration can only 'see' width , it won't be recalculated when
height changes. As a result, code is hard to refactor, and understanding the intricacies of
when Svelte chooses to update which values can become rather tricky beyond a certain level of
complexity.
Svelte 5 introduces the $derived and $effect runes, which instead determine the
dependencies of their expressions when they are evaluated:
<script>
let { width, height } = $props(); // instead of `export let`
$effect(() => {
console.log(area);
});
</script>
As with $state , $derived and $effect can also be used in your .js and .ts files.
Signal boost
SVELTE | Blog
Lik th f k ' t th li ti th t K k t i ht ll l