Svelte · Senior · Question 58 of 75

What is wrong with deriving state from props like this in a reusable component?

let { initial } = $props();
let value = $state(initial);

Explanation

Sometimes capturing the initial value is intended (e.g. a form's default); then name it clearly, like initialValue.

Further reading

Problem with a question

Svelte · Senior · question 58

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