You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime/samples/binding-this-each-key/main.svelte

16 lines
328 B

<script>
export let data = [ { id: '1' }, { id: '2' }, { id: '3' } ];
export let refs = [];
// note that this is NOT data.slice().reverse()
// as that wouldn't have triggered an infinite loop
$: list = data.reverse();
</script>
{#each list as { id }, index (id)}
<div bind:this={refs[index]}>
content
</div>
{/each}