Skip to content

Unnecessary $state in "select-bindings" tutorial for static <select> options? #1527

@becknik

Description

@becknik

Hey,
I'm currently going though the official tutorial and have noticed the following thing that won't make any sense to me:

let questions = $state([
{
id: 1,
text: `Where did you go to school?`
},
{
id: 2,
text: `What is your mother's name?`
},
{
id: 3,
text: `What is another personal fact that an attacker could easily find with Google?`
}
]);

The array here is wrapped inside a $state rune, but since it's never adjusted I'm not completely sure why that is. Removing the rune from it just seems to work flawlessly...

<select
value={selected}
onchange={() => (answer = '')}
>
{#each questions as question}
<option value={question}>
{question.text}
</option>
{/each}
</select>

Do I miss something important/ idiomatic in Svelte, or is this indeed a small mistake?

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions