Open
Description
Describe the bug
Update of $state variable overwrites it instead of update when the state variable was returned by a function.
As you can see in the 2nd log line, count2
is not a state proxy anymore.
<script>
//App.svelte
import { createStore } from './Stores.svelte.js';
let count = $state({});
let count2 = createStore();
console.log('stores', count, count2);
count = { some: 'value' };
count2 = { some: 'value' };
console.log('stores after', count, count2);
</script>
//Stores.svelte.js
export function createStore() {
let store = $state({});
return store;
}
Reproduction
Logs
- stores Proxy(Object) {} Proxy(Object) {}
- stores after Proxy(Object) {some: 'value'} {some: 'value'}
System Info
Svelte 5.0.0-next.251
Severity
blocking an upgrade