Hacker News new | ask | show | jobs
by hfourm 2027 days ago
I wish a lot of the React conversation would focus in on WHY it is so popular even for apps it shouldn't be.

In my mind the mental model shift towards completely modular components including their CSS(in JS), behavior and Dom/html(jsx) is just a very pleasant front end development model.

Its hard to go back to the old ways once you have experienced the productivity of React. I say this while obviously acknowledging dealing with the tooling ecosystem can be frustrating at times.

3 comments

This is it, for me. I don’t want React, but I want (a subset of) its API. I’m building a site with Next.js which in theory should be 99+% static and it should be able to ship with a very small JS footprint. But by default all that static junk gets bundled up anyway. And stripping it out would require a lot of manual work, or building yet another layer of build tooling that would be wonderful to have but is pretty daunting to think about.
There's an experimental flag for disabling runtime JS on a per-page basis in Next.js. Not sure when it will land, but the Next.js team is trying to add this directly into the framework.
That’s cool and I was reading about it today. But it’s really not what I want. I’d like to have a mostly static site but still be able to ship interactive components where they’re actually interactive. What I want, in order of preference (lowest to highest):

- The ability to specify that a given component is static and should never hydrate (and never bundle in the build as a result). There’s a bunch of proofs of concept of this out there, it’s definitely a better UX, but it’s not a good DX. It’s a fight to set up, entirely manual, and generally opt in (which means you’re more likely to ship broken components if you forget to opt in, whereas opt out is more likely to deoptimize by mistake)

- Static analysis to determine where components are constant at build time and automatically strip them from the build/hydration flow.

- Compile to DOM operations like Svelte.

Basically, I want a Svelte build with a React/JSX interface.

I’m certain it’s possible, given a long enough timeline. I’m not sure how well it would work with real world React code, as hooks and context could deoptimize whole pages in unexpected ways. And that’s frankly where I wish for a much simpler React subset for this use case.

It helps with working with a team of people with varying mental models.

If React didn’t exist, every team member would have their own way of writing up, I don’t know, a multi-select drop down component. With React, you can nip a little bit of creativity out of each individual team member for sanity’s sake. You would be shocked just how different people’s mental models actually are without a framework.

I already go nuts at how some people structure some components, and to keep this post at peak hyperbole, I’d give up on life if I had to see their vanilla js components.

It would be unmanageable emotionally. I’ve seen some people write components that are straight up php-like includes (e.g import ‘./FilterCategories’. Doesn’t take any args. Just for sanity’s sake, the fact that React is helping teams write composable/reusable modules (or that a module is a function that takes params, so don’t be a dick and make a shrink wrapped component with vars baked in), with brain-dead ways of wiring up component logic is probably one of the most stress-reducing advents in frontend.

Lots of finger pointing by me here, but I’m doing it to vent to strangers, instead of taking it out at work.

> I wish a lot of the React conversation would focus in on WHY it is so popular even for apps it shouldn't be.

I didn't think this was a mystery. It's because a lot of devs are coming into the web ecosystem having primarily learned frameworks at boot camps (or on their own).

Most front-end devs that I've worked with who started in the last 5-10 years have such framework-specific knowledge that they can't really jump between frameworks or work on vanilla JS.

I'm not saying this is categorically bad. I use heavy abstractions on top of web languages (TypeScript, Webpack, Sass, Svelte) even for static sites, so I'm not arguing that they should be writing vanilla JS.

It's just interesting that JS is so flexible, and some of these abstractions are so strong, that you can learn something like React without really learning JS at all. It's like a DSL on top of JS.

JSX abstraction exists not because JS is so flexible but because it has a separate compiler for the code.

Otherwise if you don’t use JSX then you get something akin to programming with Ruby on Rails or Django - still quite integrated, but the syntax is familiar.

I actually didn't mean to include JSX in any of my comment. It is a DSL unquestionably.

I meant that the JS you write in React, Vue, and Svelte feels like a DSL.