-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed as not planned
Description
Describe the bug
I am not sure, if this is intended, but to me this behavior is very strange:
- create a variable with the state rune and a SvelteMap as value
- add a react rune to trigger some side effects. The changes will not be tracked, but if you wrap it with Array.from, it will.
<script>
import { SvelteSet } from "svelte/reactivity"
let fruits = $state(new SvelteSet(['foo', 'bar']))
/* does not work */
$effect(() => {
console.log("effect", fruits)
});
/* works */
$effect(() => {
console.log("effect with Array", Array.from(fruits))
});
</script>
<h1>Hello {JSON.stringify(Array.from(fruits))}!</h1>
<button onclick={()=>fruits.add('banana')}>Banana!</button>
Reproduction
Logs
System Info
System:
OS: macOS 14.5
CPU: (10) arm64 Apple M2 Pro
Memory: 154.13 MB / 32.00 GB
Shell: 3.6.1 - /usr/local/bin/fish
Binaries:
Node: 22.10.0 - ~/.local/share/nvm/v22.10.0/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.9.0 - ~/.local/share/nvm/v22.10.0/bin/npm
pnpm: 8.7.6 - /usr/local/bin/pnpm
bun: 1.0.13 - ~/.bun/bin/bun
Browsers:
Chrome: 133.0.6943.142
Edge: 133.0.3065.92
Firefox Nightly: 137.0a1
Safari: 17.5
npmPackages:
svelte: ^5.17.0 => 5.17.0Severity
annoyance
Metadata
Metadata
Assignees
Labels
No labels