Comments (2)
I lean towards marking this as "works as designed". We can't know the intention of someone putting state from one place into another. We err on the side of caution to not produce (much more annoying/bad) false positives which, depending on what you're doing, may result in a false negative in some cases.
The underlying system assumes that assinging state to another state means that the ownership is widened. Changing this heuristic would come with signifant drawbacks and I'm not sure we could keep the current validation strategy in that case. Therefore closing.
from svelte.
I'm fine with just remembering not to do it, but...
I'm pretty sure that "duplicating" state like this, be it directly mutable (from $state
,) derived, bound or unbound, is always a mistake, or at least an anti-pattern. It can't be good to have two mutable states pointing to two states that can directly mutate the same / overlapping / nested prox(ies). And there's really no use case. If a component needs extra state to do its job, surely the pattern should be:
- init the extra state from props (making sure to remove reactivity)
- update the bound prop from
$effect
or a function.
from svelte.
Related Issues (20)
- Petition to NOT deprectate slots in Svelte v5 HOT 11
- Svelte 5: `ComponentType` is still a constructor HOT 3
- Svelte 5: Auto completion implies that you can access state from another file even tho you cant HOT 3
- Svelte 5: Flaky State Ownership Warning - ownership_invalid_binding HOT 2
- Svelte 5: Assigning `this` to variable exposes signals
- svelte 5: suggestion to add an optional argument to the $effect cleanup callback to know if the effect is being destroyed or re-ran HOT 8
- Svelte 5: Whitespace problem in typed parameters to snippets HOT 2
- Svelte 5: Cannot use rest arguments in snippets HOT 1
- Using `this` alias breaks reactivity HOT 6
- Svelte 5: Chained `$derived`s don't update sometimes HOT 2
- Svelte 5: behavior of svelte-ignore is different between Svelte 4 and Svelte 5 HOT 3
- Svelte 5: faulty ownership_invalid_binding errors are back, inside #if blocks
- Svelte 5: flip animation breaks entry transition with delay HOT 1
- Svelte 5: ComponentProps does not correctly resolve conditional property types HOT 4
- A rare bind value bug sets the value to null when it is not bind in parent HOT 3
- Error de CORS en Rutas api de Sveltekit HOT 1
- Svelte 5: `<img loading="lazy">` loads eagerly in Firefox (regression) HOT 5
- Svelte 5: Two-way-binding of superforms $formData is broken if passed as arg in render snippet HOT 3
- Svelte 5: Increment(++) and Decrement(--) operator output is incorrect
- Svelte 5: differentiate between supported and unsupported TypeScript features
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.