You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to convert a JS object into a keyed each block in svelte, but the compiler/REPL are both yelling at me about the syntax. Attempting it with or without destructuring doesn't appear to matter, but I tried both for good measure.
<!-- Without Destructuring -->
{#each Object.entries(objects) as object (object[0])}
<div>{object[0]}, {object[1]}</div>
{/each}
<!-- With Destructuring -->
{#each Object.entries(objects) as [ key, data ] (key)}
<div>{key}, {data}</div>
{/each}
<script>exportdefault{data : ()=>({objects : {"1" : "one","2" : "two",}})};</script>
Do keyed each blocks only support sub-properties of the current iteration value? I can re-structure my data to support that but it seems like the iteration value (or any destructured values from the iteration value) should be valid to use as the key.
The text was updated successfully, but these errors were encountered:
tivac
changed the title
Unable to use object keys for keyed {#each} blocks
Unable to use iteration value for keyed {#each} blocks
Apr 26, 2018
Trying to convert a JS object into a keyed each block in svelte, but the compiler/REPL are both yelling at me about the syntax. Attempting it with or without destructuring doesn't appear to matter, but I tried both for good measure.
REPL version
Do keyed each blocks only support sub-properties of the current iteration value? I can re-structure my data to support that but it seems like the iteration value (or any destructured values from the iteration value) should be valid to use as the
key
.The text was updated successfully, but these errors were encountered: