- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 4.7k
 
Closed as not planned
Description
Describe the bug
The effect in the following code is looping indefinitely:
<script>
	let x = $state(0);
	let y = $state({a: 0});
	$effect(() => setY(x));
	function setY(newX){
		y = {a: 1};
		console.log($state.snapshot(y));
	};
</script>Converting the first line in the function to y.a = 1 fixes the problem. Commenting out the second line (the one with console.log
) also does.
Reproduction
Logs
System Info
Tested with Svelte 5.22.5 (locally) and 5.23.2 (REPL)Severity
blocking all usage of svelte
Metadata
Metadata
Assignees
Labels
No labels