mirror of https://github.com/sveltejs/svelte
parent
5a899c2244
commit
0e1cdd9e52
@ -1,21 +1,20 @@
|
|||||||
<script>
|
<script>
|
||||||
const {log} = $props();
|
const {log} = $props();
|
||||||
|
|
||||||
let myList = $state([{ name: 'one' ,age: 4 }, {name: 'two', age: 5}]);
|
let s = $state(0);
|
||||||
|
let d = $derived(s)
|
||||||
let myDerived = $derived(myList)
|
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
myList
|
s;
|
||||||
log.push('A')
|
log.push('A')
|
||||||
})
|
})
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
myDerived
|
d;
|
||||||
log.push('B')
|
log.push('B')
|
||||||
})
|
})
|
||||||
</script>
|
</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