Runes란
Svelte 5는 기존 $: 반응성 선언 대신 Runes라는 새로운 시스템을 도입했습니다. 명시적이고 예측 가능한 반응성을 제공합니다.
$state와 $derived
<script>
let count = $state(0);
let doubled = $derived(count * 2);
function increment() {
count++;
}
</script>
<button onclick={increment}>
{count} x 2 = {doubled}
</button>$effect
$effect는 의존성을 자동으로 추적하여 부수 효과를 실행합니다.
댓글 0