-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed as duplicate of#10560
Description
Describe the bug
state rune reactivity does not work when using an object which has been "newed" from an Java or Typescript class
<script>
class MyJSclass {
count = 0;
}
let jsclazz = $state(new MyJSclass());
</script>
counter { jsclazz.count }
<button onclick={()=>jsclazz.count++}>increase</button>when the rune declaration
let jsclazz = $state(new MyJSclass()); is changed to
let jsclazz = $state({...new MyJSclass()}); it works as expected.
Reproduction
<script>
class MyJSclass {
count = 0;
}
let jsclazz = $state(new MyJSclass());
</script>
counter { jsclazz.count }
<button onclick={()=>jsclazz.count++}>increase</button>Logs
System Info
any svelte5 system, online REPL or freshly scaffolded svelte5 appSeverity
annoyance
Metadata
Metadata
Assignees
Labels
No labels