Svelte · Junior · Question 61 of 76

What happens with reactivity here?

let user = $state({ name: "Ann" });
let { name } = user;
user.name = "Bob";
// name === ?

Explanation

Like in plain JavaScript, destructured values aren't live. Read user.name or use $derived.

Further reading

Problem with a question

Svelte · Junior · question 61

Test yourself

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

Take this quiz