Skip to content

[Svelte 5] get a item of array in each block by index return indefined #9629

@CodexKI

Description

@CodexKI

Describe the bug

when i get an element of array in the each block return undefined

Reproduction

playground
`

<script> let {items=[]} = $props(); </script>

{#each items as item, i}
{#if i == indexItem}
<img
...
bind:this={items[i].img}
...
/>
{/if}
{/each}
`

//update
works when change the 70 line for bind:this={item.img}

Logs

No response

System Info

Cannot read properties of undefined (reading 'img')

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions