Svelte: Store binding inside each is broken

Created on 23 Aug 2019  路  2Comments  路  Source: sveltejs/svelte

Describe the bug

This doesn't work:

{#each $items as item, index}
  <input bind:value={item.text}>
{/each}

To Reproduce

https://svelte.dev/repl/358a3620fd6b4f159a90268a6b2035a4?version=3.9.1

Expected behavior

Editing the text input should update the store

Severity

Seems bad

Additional context

https://stackoverflow.com/questions/57626273/svelte-component-not-re-rendering-with-new-values-if-text-input-is-inside-an-eac

bug

Most helpful comment

As a workaround, this works:

<input bind:value={$items[index].text}>

Might help track down how to correct it.

All 2 comments

As a workaround, this works:

<input bind:value={$items[index].text}>

Might help track down how to correct it.

@Rich-Harris , it still breaks with use directive. instead ofbind:valuein the example if you use use:setValue , anything updated in the function is not reflected. Could you please help?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Rich-Harris picture Rich-Harris  路  3Comments

sskyy picture sskyy  路  3Comments

angelozehr picture angelozehr  路  3Comments

plumpNation picture plumpNation  路  3Comments

1u0n picture 1u0n  路  3Comments