-
-
Notifications
You must be signed in to change notification settings - Fork 209
Improve Visibility of Reactive Variables #2188
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
Comments
Perhaps, more than visibility, we could use a so that way we could also state that a prop (which are not reactive by default) are required to be reactive, just like we did when we needed a |
Types do not work, they would falsely transfer on assignment to non-reactive variables (like a |
haven't thought about it, it would be great to find a workaround to let the type system be aware of reactive values |
From the docs: https://react.dev/learn/lifecycle-of-reactive-effects#all-variables-declared-in-the-component-body-are-reactive Quote: Props and state aren’t the only reactive values. Values that you calculate from them are also reactive. If the props or state change, your component will re-render, and the values calculated from them will also change. |
Description
This is most relevant to Svelte 5, but is also applicable to prior versions.
Reactive variables and non-reactive variables are co-located in your code when writing a Svelte app.
This may cause some minor inconvenience when you need to check the implementation to determine whether a variable is reactive or not.
This may also be inconvenient for beginners who might not know what is reactivity is.
For example:
$myStore
subscribe syntax, it will not be reactive.$state
andlet
Proposed solution
Reactive variables (state/derived/stores) visual cues:
(Additional possibilities/features)
Show side effects of a state assignment
=
:Show dependencies of a reactive variable:
Alternatives
Other ways to visually indicate reactive variables:
Additional Information, eg. Screenshots
A visual distinction between reactive and non-reactive variables could add clarity and improve elegance in the sense of having reactive/non-reactive variables co-located.
Note: reddit post
Below shows an example in Svelte 5 (as-of the current early preview) of what it could look like before and after adding proposed features:
The text was updated successfully, but these errors were encountered: