Coder Social home page Coder Social logo

Comments (4)

deluksic avatar deluksic commented on June 12, 2024 1

If this was easy to do, it would have been the default. The problem with it is that it doesn't work with reactivity where "reading is subscribing". This relies on getters. You can't implement the subscribe part if you destructure, as the component function body never reruns.

There is a community driven props destructuring plugin that rewrites your code, but I don't know how good that works. I feel like less compiler magic is better, but you have options for sure.

from solid.

pureliani avatar pureliani commented on June 12, 2024

If this was easy to do, it would have been the default. The problem with it is that it doesn't work with reactivity where "reading is subscribing". This relies on getters. You can't implement the subscribe part if you destructure, as the component function body never reruns.

There is a community driven props destructuring plugin that rewrites your code, but I don't know how good that works. I feel like less compiler magic is better, but you have options for sure.

Yes, i know that reactivity is lost when destructuring, but with the help of a compiler i don't think this would be an issue, i think this is the plugin which already does it, and to me this doesn't feel like compiler magic, more like, smoothening sharp edges of solidjs to make it look more like regular js

from solid.

deluksic avatar deluksic commented on June 12, 2024

Imo its magic because it (seems to) only work when having annotations on your functions which make them components. It is already pretty hard to get people who are used to react to understand reactivity. Now if you say, sometimes destructuring works, but only if you have this special annotation, that will be even more confusing. Personally, I would support this being core only if you can globally sove for this.

P.S. this would be better as a discussion than an issue. As it has been brought up many times.

from solid.

ryansolid avatar ryansolid commented on June 12, 2024

I agree. If anything this is better as a discussion. As @deluksic unless there was some unavoidable and automatic way to identify components this would never work. And more over it would take more than just handling function signatures if you wanted any sort of consistency. The complexity there is hard to merit.

Not that we are at that state now anyway. If we were to try to implement this it would make sense only to people already well aware of the problem, making the solution not any better than the problem as it interfere with teaching. Like why does certain things work and not others. It again requires too much specific knowledge.

from solid.

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.