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";- ✓Correct answer: It's computed once at creation; use
let color = $derived(type === "danger" ? "red" : "green") - 2Props are never reactive
- 3
typemust be marked$bindable
Explanation
Treat props as values that can change: anything computed from them should be derived.