Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I’ve heard, especially during the first few years when react was introduced, that you don’t need templating, compiler, or anything special to write react, “it’s just JS”.

Of course you CAN write anything you want inside a component, but then it breaks, or has awful performance. To write components the proper way you can’t use any control flows with state management, you need to keep remembering which are the correct dependencies to recreate state, it makes components 20% BL and 80% react logic.

You can’t use if-else in JSX, since only expressions are allowed. So you need to create nested ternaries, which are hard to read, or using JS anomalies like having a condition expression return the last truthish evaluation.

And regarding signals, preact is using it and it doesn’t seem to break anything there.

Function of a state has a nice ring to it, but eventually this was solved a long time before react, every templating engine is a function of a state. The hard part is composing the state easily which react has never been able to achieve.



> that you don’t need templating, compiler, or anything special to write react, “it’s just JS”

This is still true. I don't currently use any of those things. And the existance of a compiler does imply you can't write Javascript. Totally different concepts. Also, pretty sure they had compiler plans for like years now.

> but then it breaks, or has awful performance.

You're gonna have to be more specific. I could repeat that sentence for every programming language/library on the planet and without specifics it would make sense.

> You can’t use if-else in JSX,

I don't need to use if-else in JSX to control flow. I can write if(condition) return html;

> which are hard to read, or using JS anomalies like having a condition expression return the last truthish evaluation.

See the sentence I just wrote before this. I can use if/else to control flow and return early without templating. How is that not ideal?

> And regarding signals, preact is using it and it doesn’t seem to break anything there.

It's not about literlaly "breaking" something. They could implement htem if they wanted to. It's about breaking the mental model.

In React, data flows down. That's a constraint, but not always a bad one. I know exactly where to look for data (up). With signals, that's throw out the window. And now, it's not just about what the component accepts via props/context (which again, is down) it now needs to turn itself on it's head.

I used Angular for years before React and I do not miss having things talking to each other throw multiple lateral levels.

> Function of a state has a nice ring to it, but eventually this was solved a long time before react, every templating engine is a function of a state.

> Function of a state has a nice ring to it, but eventually this was solved a long time before react, every templating engine is a function of a state. The hard part is composing the state easily which react has never been able to achieve.

This is incredibly misleading (and wrong). Templates don't compose. And React is quite literlaly the king of composition.

It's starting to feel like you've never actually used React, but instead are basing your opinions on what you see other people say (who have also not used React).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: