-
-
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 statements and unexpected line execution order #4516
Comments
I don't think either of these are bugs, but they're probably something we should document somewhere. The second one definitely isn't a bug, because we need to topologically sort the reactive blocks according to what depends on what. The first reactive block depends on Given that we're reordering the blocks, having them be 'inline' with the rest of rest of the static top-level statements doesn't really make sense (not to mention the question of whether it would be considered a breaking change). |
What about adding a dev warning for reactive statements that aren't reactive ? And yes that really should be highlighted in the docs since being able to pool together static top level and reactive statements heavily implies that they can interact with each other edit : another idea could be to have the officially supported formatter reorder the lines in the order they run in |
I wrote a custom lint rule that tries to identify static assignments in reactive blocks, it's not very smart but it helped us catch a couple instances of this sort of thing. |
Closing because reactive statements are deprecated in Svelte 5 |
The compiler reorganizes the order at which lines are run such that reactive statements are only run at the end, that already by itself creates unexpected output such as :
but then, when you'd expect reactive statements to at least keep the right order between themselves, this happens:
the current component initialization order is the following :
related : #4371
The text was updated successfully, but these errors were encountered: