mirror of https://github.com/sveltejs/svelte
parent
5a899c2244
commit
0e1cdd9e52
@ -1,21 +1,20 @@
|
||||
<script>
|
||||
const {log} = $props();
|
||||
|
||||
let myList = $state([{ name: 'one' ,age: 4 }, {name: 'two', age: 5}]);
|
||||
|
||||
let myDerived = $derived(myList)
|
||||
let s = $state(0);
|
||||
let d = $derived(s)
|
||||
|
||||
$effect(() => {
|
||||
myList
|
||||
s;
|
||||
log.push('A')
|
||||
})
|
||||
|
||||
$effect(() => {
|
||||
myDerived
|
||||
d;
|
||||
log.push('B')
|
||||
})
|
||||
</script>
|
||||
|
||||
<h1>Hello {myList[0].age}</h1>
|
||||
<h1>{s}</h1>
|
||||
|
||||
<button on:click={() => myList[0].age++ }>Click</button>
|
||||
<button on:click={() =>s++ }>Click</button>
|
||||
|
Loading…
Reference in new issue