3 ms·
Why? React’s component model can be an excellent abstraction for building a “normal website”—or rather, its component parts—for developers who prefer it. React
by eyelidlessness 3y ago
Why? React’s component model can be an excellent abstraction for building a “normal website”—or rather, its component parts—for developers who prefer it. React can compile to static HTML, without running any JS client side, and/or can be used to mount or hydrate arbitrary subtrees however one sees fit. (I’d probably favor Preact or Solid for the latter, but React is a perfectly cromulent choice)
- afavour 3y agoReact can be used without JS or by hydrating subtrees but those are very uncommon. It’s certainly not React’s “happy path”.
- kamikaz1k 3y agoLiterally just a single API call: renderToString https://react.dev/reference/react-dom/server/renderToString https://react.dev/reference/react-dom/server/renderToString
- afavour 3y agoYes, I’m very aware, but renderToString is designed for later client side hydration. To make your point you would have wanted to cite renderToStaticMarkup, but tellingly no-one ever does.
- eyelidlessness 3y agoRendering to static HTML is actually pretty common. Admittedly, hydrating subtrees is fairly uncommon (at least where the full tree is also rendered by React server-side), but it’s well within the “happy path” and both patterns have been heavily promoted by React from very early on. What’s not within the “happy path” is automating any sort of partial hydration process, which is unfortunate, but it seems pretty likely RSC is going to subsume that use case for most anyone trying to solve it with React.
- zilti 3y agoOr just be a sane person and use HTML, CSS, and templates, and sprinkle some HTMX on top for interactivity.
- eyelidlessness 3y agoWhat is the sane person’s templates?