Giter VIP home page Giter VIP logo

Comments (2)

dummdidumm avatar dummdidumm commented on June 9, 2024

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.

cdcarson avatar cdcarson commented on June 9, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.