Live data from Hacker News

Solid.js feels like what I always wanted React to be

typeofnan.dev

11–20 of 444 posts

Re: Solid.js feels like what I always wanted React to be

#11
Regarding the example under "Reactivity, not lifecycle hooks":

Does the component reference the same outer "count"? So is "count" here global or local to the component? In other words, what is the scope of "count"? Does it change based on where it is placed? If I create multiple components, do they all reference the same "count" or is it different for each component?

Sorry this question might seem naive if you are experienced in SolidJS. I haven't given SolidJS a shot yet (though it is on my list of things to check out).

Re: Solid.js feels like what I always wanted React to be

#13
New JS frameworks always make for compelling hello world examples.

Can you branch on state or use loops over data in Solid.js? The reason _why_ React has a virtual DOM is to enable more interesting relationships between your data and your presentation. Anyone can make a framework that makes the source code for an incrementing number look pretty!

As an example of this point, check out the "Simple Todos" example for Solid.js[1].

In React, we render lists by using regular JavaScript idioms like loops, arrays, and array methods like map. However in Solid.js, much like traditional templating languages, we get a construct like that reinvents a concept that's already in the language.

I've been writing React and React-alike code for a long time. I think that fine-grained updates avoiding reconciliation are a good idea, especially for performance. At one point, I built a React-like library for Roblox and Lua whose most novel feature ended up being "Bindings"[2], which look sorta like Solid.js state containers. They create little hot-path data dependencies, but the bulk of your components still use normal React-like rendering.

  [1]: https://www.solidjs.com/examples/todos
  [2]: https://roblox.github.io/roact/advanced/bindings-and-refs/

Re: Solid.js feels like what I always wanted React to be

#15
Every time I see stuff like this

    componentDidMount() {
I get driven away from React. It looks haphazard. Seriously? What about

    componentDidntMount() {

    componentWantedToMountButDidnt() {
...

I'm used to clean naming conventions like

    void Component::on_mount() {
        ....
    }

Re: Solid.js feels like what I always wanted React to be

#16

New JS frameworks always make for compelling hello world examples. Can you branch on state or use loops over data in Solid.js? The reason _why_ React has a virtual DOM is to enable more interesting relationships between your data and your presentation. Anyone can make a framework that makes the source code for an incrementing number look pretty! As an example of this point, check out the "Simple Todos" example for So…

> we get a construct like that reinvents a concept that's already in the language

Isn't this optional? Can't Solid use regular JSX loops?

Re: Solid.js feels like what I always wanted React to be

#17
"That’s a lot of code to write for an auto-incrementing counter"

In reality, you will never need to write an auto-incrementing counter :) React gives you a mental framework, you draw a page based on the state in a declarative way. The clever abstraction you make, the less you write the code, so it's a little bit pointless to compare it with an auto-incrementing counter application, in reality has no use case at all.

Re: Solid.js feels like what I always wanted React to be

#18
post #16

New JS frameworks always make for compelling hello world examples. Can you branch on state or use loops over data in Solid.js? The reason _why_ React has a virtual DOM is to enable more interesting relationships between your data and your presentation. Anyone can make a framework that makes the source code for an incrementing number look pretty! As an example of this point, check out the "Simple Todos" example for So…

> we get a construct like that reinvents a concept that's already in the language Isn't this optional? Can't Solid use regular JSX loops?

https://www.solidjs.com/docs/latest/api#control-flow

For reactive control flow to be performant, we have to control how elements are created. For example, with lists, a simple map is inefficient as it always maps the entire array.

This means helper functions.

Re: Solid.js feels like what I always wanted React to be

#19

Regarding the example under "Reactivity, not lifecycle hooks": Does the component reference the same outer "count"? So is "count" here global or local to the component? In other words, what is the scope of "count"? Does it change based on where it is placed? If I create multiple components, do they all reference the same "count" or is it different for each component? Sorry this question might seem naive if you are ex…

I think the count variable is quasi an Rx subject, it has identity and any code using it is keeping a hard reference on it. It would probably be GC‘d if nobody referenced it. In my understanding, yes, multiple components would use the same instance of count.

Re: Solid.js feels like what I always wanted React to be

#20
post #10

I swear we're just going around in circles because people only have a surface level understanding of these front-end frameworks, and the challenges with building at scale. react isn't about 'hooks', 'jsx', 'top-down-state', or 'component-driven architecture'. All these frameworks are component-based, can have top down state only (or do bottom up in react), can use things like jsx/hooks because it's just syntactic sug…

The thing is that While react is against side effects, javascript is not. Which result in these impedance mismatch where what devs want is against react itself.

Vue/svelte/solid do not fight against js, hence they do not end up in similar situation

Post reply on HN