Closed
Description
Describe the bug
- if uncomment $effect() or $inpect()
counter.count
not update
<script>
let counter = $state({
count: 0,
increment(){this.count += 1},
});
/* Any of the following lines breaks the updates */
// $effect(() => { console.log(counter) });
// $inspect(counter)
</script>
<button onclick={counter.increment}>
clicks: {counter.count}
</button>
- The following fragment causes a loop when invoking increment
<script>
let counter = $state({
count: 0,
increment: () => {
this.count += 1; /* `this` is undefined obviously */
},
});
</script>
<button onclick={counter.increment}>
clicks: {counter.count}
</button>
clicking causes a loop
Reproduction
Logs
No response
System Info
(Svelte v5.0.0-next.60)
Severity
annoyance
Metadata
Metadata
Assignees
Labels
No labels