Svelte · Middle · Question 11 of 75

Why does color not update when the type prop changes?

let { type } = $props();
let color = type === "danger" ? "red" : "green";

Explanation

Treat props as values that can change: anything computed from them should be derived.

Further reading

Problem with a question

Svelte · Middle · question 11

Test yourself

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

Take this quiz