Closed nvlang closed 2 hours ago
$state
does not affect classes, there are reactive versions of built-ins like Set
and Map
that can be imported from 'svelte/reactivity'
.
https://svelte-5-preview.vercel.app/docs/runes#$state Yup. $state
only makes POJOs deeply reactive, and there are reactive versions of these other types of objects.
Ah, my bad, sorry I missed that. Thank you!
Describe the bug
I noticed that the
$state
rune doesn't work as expected for objects of typeMap
orSet
. In particular, there doesn't seem to be any reactivity when declaring something likeconst map = $state(new Map())
and then updatingmap
.Apologies if this is by design, I couldn't find documentation about it or another issue describing this behavior.
Reproduction
Link to reproduction in REPL
This is the gist of it:
For
Set
s:For
Map
s:Logs
No response
System Info
Severity
annoyance