Svelte · Senior · Question 4 of 75

Why does this effect run only once, even though state.value changes?

let state = $state({ value: 0 });

$effect(() => {
  console.log(state);
});

Explanation

An effect reruns only when what it actually read changes. To log deep changes during development, use $inspect(state).

Further reading

Problem with a question

Svelte · Senior · question 4

Test yourself

Take the Svelte · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz