You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the imperative component API using a class in a svelte.js file, declaring the $state as a class field, then imperatively updating a prop, it did not react to changes properly. Notably, I found I could make it work if I added the $inspect rune to examine this prop
This was an annoyance when trying to migrate from svelte 4 to svelte 5 -> previously it could use $set() and that worked fine. The workaround was to fully migrate anything using the imperative API to runes mode, and initialize the $state in the .svelte file. The reason for using a class field is so that I can continue to use svelte components with ag grid -> for example here is their "ICellRenderer" interface, but here I provide a minimal example.
Describe the bug
When using the imperative component API using a class in a
svelte.js
file, declaring the $state as a class field, then imperatively updating a prop, it did not react to changes properly. Notably, I found I could make it work if I added the $inspect rune to examine this propThis was an annoyance when trying to migrate from svelte 4 to svelte 5 -> previously it could use $set() and that worked fine. The workaround was to fully migrate anything using the imperative API to runes mode, and initialize the $state in the
.svelte
file. The reason for using a class field is so that I can continue to use svelte components with ag grid -> for example here is their "ICellRenderer" interface, but here I provide a minimal example.Reproduction
REPL Link
Code
App.svelteBroken.svelte:
utils.svelte.js
FixedByInspect.svelte
Initial State:
After Clicking:

Notice that the
p1 === undefined
branch contents is not removed as expectedSystem Info
I ran this in the svelte.dev playground - compiler version was 5.25.6
Severity
annoyance
The text was updated successfully, but these errors were encountered: