I add item to first position of a list. In {#each} section, loop the list and show each item with component. The source is here (REPL) and below. Everytime I add item, it show different item i add on the bottom, despite of I add item on the top of list.
Does anyone know what cause this?
App.svelte
<script>
import ListItem from "./listItem.svelte";
let list = [
{id : [1,2,3,4,5]},
{id : [3,4,5,6,7]}
];
function addItem(){
list = [
{id:[5,6,7,8,9]}
, ...list
]
console.log(list)
}
</script>
<button on:click={addItem}>click</button>
{#each list as item}
<ListItem data={item}/>
{/each}
listItem.svelte
<script>
export let data = {};
let ids = data.id.join(' ');
</script>
<div>
{ids}
</div>