-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Description
Describe the bug
Previously with Svelte 4, a let variable could be a Set and still be reactive, it was just necessary to re-assign its value. Now in Svelte 5, that does not work anymore.
Reproduction
here is a minimal example:
<script>
// Create a reactive variable using a Set
let setVariable = $state(new Set());
// Interval to add to the set every 2 seconds
let counter = 0;
setInterval(() => {
counter++;
setVariable.add("hello" + counter);
console.log(setVariable); // Log the set contents to see changes
setVariable = setVariable; // Even this does not make it reactive
}, 2000);
</script>
<h1>Hello {setVariable.size}!</h1>
<p>Check the console to see the contents of the set!</p>
The DOM does not update at all, even when I reassign the value. This worked in Svelte 4.
Logs
The logs show that the Set itself updates.
System Info
Firefox
Severity
blocking an upgrade
Metadata
Metadata
Assignees
Labels
No labels