Skip to content
Discussion options

You must be logged in to vote

Because it can be a derived array

{#each todos.filter(isActive) as todo, i}
    <TodoItem bind:todo={todo} {removeTodo}/>
{/each}

or not an array (#each accepts any iterable object):

{#each todoMap.values() as todo, i}
    <TodoItem bind:todo={todo} {removeTodo}/>
{/each}

and totally unclear to what bind todo. And even in a case like

{#each myObject.someField as todo, i}
    <TodoItem bind:todo={todo} {removeTodo}/>
{/each}

someField may each time return a new array that is not supposed to be mutated.

For these reasons, we require explicitness here.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@Nonlinearsound
Comment options

Answer selected by Nonlinearsound
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants