-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Svelte 5: ERR_SVELTE_TOO_MANY_UPDATES when updating state #9712
Comments
As far as I understood $effect, to me, it is not a good practice to reassign values while in an $effect. Unless you are using <script>
import { untrack } from 'svelte';
let x= $state({ count: 0 });
$effect(() => {
untrack(() => {
x.count += 1;
});
});
</script> |
Also, use guards: $effect(() => {
if (x.count !== 1) {
x.count = 1;
}
}); In other cases, turn the used variables into primitives or separate the effect's dependencies and mutated variables |
This would be fixed by #9685, but we're holding off merging that because we have a more comprehensive update in the works that will change the behaviour around this stuff. We'll open a PR soon |
Fixed in svelte@5.0.0-next.18 |
Describe the bug
This code leads to ERR_SVELTE_TOO_MANY_UPDATES,
while this doesn't cause any error,
Looks like a reactivity bug.
Reproduction
Svelte 5 REPL with Error
Svelte 5 REPL without Error
Logs
No response
System Info
Severity
blocking an upgrade
The text was updated successfully, but these errors were encountered: