Comments (3)
You're running into an edge case here with the rerender heuristic. Svelte batches identifiers (foo
) and member expressions (foo.bar
) into one render effect to save memory and for better performance. The thought process is that identifiers cannot have side effects, and getters should never have.
In your case, everything's in one render effect, but it will only update if you actually modify a reactive variable. The last non-state is never updated because Svelte can detect that it's a non-reactive variable (because it's in scope and can be statically analyzed).
Closing as this heuristic was chosen deliberately.
from svelte.
I have understood your message through the translation.
In that case, how can we create non-reactive variables using class syntax? (It seems like you mentioned it's not possible...)
With functional syntax, non-reactive variables can be created and simply returned.
Am I correct in understanding that there is a difference in declaring non-reactive syntax between functional and class syntax, and that I should use functional syntax when necessary? (In other words, there are limitations with class syntax.)
from svelte.
The variable is not reactive in the sense that it will never trigger an update somewhere else. But if that variable happens to be read together with other variables that are in a reactive context and therefore rerun, then the current value will be used.
from svelte.
Related Issues (20)
- Improve message for error "Nesting selectors can only be used inside a rule"
- Svelte 5: Regression since 5.0.0-next.162 with #each or render HOT 1
- Svelte v4 code running with Svelte v5: Function passed as slot variable is no longer a function when consumed HOT 5
- Svelte 5 - Relax Variable Naming Restrictions on $-Prefixed Variables HOT 7
- Svelte 5: Components in #if blocks don't trigger their $effect rune HOT 3
- False positive error: rune outside svelte
- Bump all dependencies before final release
- Documentation Clarification for Rookies HOT 3
- Svelte 5 (5.0.0-next.167): Upgrading to the latest Svelte 5 breaks SvelteKit routing HOT 7
- Svelte 5: this type of directive is not valid on components HOT 4
- [Svelte 5] `{#if}` block with several reactive children does not re-render properly HOT 11
- Svelte 5 legacy: transition not working with svelte:element
- next.167 breaks <svelte:component> in development mode
- Sveltekit + Svelte 5: Navigating only loads the layout, not the page HOT 2
- Svelte 5: Mutating data in load fn stops page reactivity HOT 2
- Svelte 5: this type of directive is not valid on components HOT 4
- Svelte 5: Inaccurate Error Message HOT 1
- `batch` function to update multiple sources at once HOT 4
- Svelte 5 reporting invalid type error on Svelte 4 component using slot
- Make aria- dependencies optional
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svelte.