I am new to Svelte, so I suspect this is a very fundamental lack-of-understanding issue.
Can someone explain why the on:click updates the UI, but the UI will not update if I attempt to use the changeJob(items)? The console.log indicates all jobs were changed in the array, but the UI does not reflect that.
<script>
import ListItem from './ListItem.svelte';
let items = [
{ name: 'John', age: 23, job: 'plumber'},
{ name: 'Jane', age: 45, job: 'hair stylist'},
{ name: 'Juan', age: 18, job: 'student'},
];
const changeJob = (arr) => {
console.log(arr[0].job);
arr[0].job = 'clown';
console.log(arr[0].job);
}
</script>
<button on:click={() => items[0].job = 'clown'}>Clownify</button>
<ul>
{#each items as item }
<ListItem {...item}/>
{/each}
</ul>
Code snippet: REPL