-
-
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
$: reactive statement ignored during beforeUpdate #8750
Comments
@ibmua I've been able to recreate what you've described in learn.svelte.dev, but after creating this repro repl, I don't think this is a Svelte issue. Could be something about the web containers setup (I'm not really sure). Let me know if the repro accurately reproduces the scenario you've outlined |
I'm not sure I fully understand what the issue here is, but I'm intrigued by this part of the code. $: {
console.log({val1, val2, domDep}),
val2 = !val2
} If we are updating the value of val2 inside this reactive block, and the block is supposed to run each time val2 changes because we are logging it to the console. Wouldn't this cause (shouldn't this cause) an infinite loop? |
No, it doesn't. When a variable changes (marked dirty), the following happens:
Step 3 prevents infinite loops, plus proper udirting variables individually is too tricky or probably even impossible. |
Svelte 5 will change the behavior here using the new Runes API. Using |
I thought about infinite loops cause by self-triggering But maybe it would nice to be able to disable |
Closing since this will be addressed in Svelte 5 as pointed out in #8750 (comment) |
Describe the bug
$: reactive statements are ignored if values are modified in beforeUpdate.
Reproduction
Solve https://learn.svelte.dev/tutorial/update
and add
You'll see that nothing will be logged. If you add some variable changes like
you'll see they don't change
Logs
No response
System Info
Severity
Pretty serious bug
The text was updated successfully, but these errors were encountered: