Hacker News new | ask | show | jobs
by jerrygenser 820 days ago
React can be added by rendering into a dom node that's not necessarily the root of your app.

Yes, it can be used to render the entire UI app with rich state management across all pages, routing, etc.

However it can just as simply be used to render 1 complex part of an app that has an isolated but possibly complex state. In this scenario I think sprinkling react is reasonable.

1 comments

I'm admittedly out of touch with current React best practices, but "sprinkling react" isn't a phrase I'd have expected to hear based on my last contact with it. Sprinkling JavaScript or Alpine.js or HTMX, yes. But React seems to come with baggage, no?
Yeah, it seems to me if you're not buying into the entire app being based on React, including JSX with Router/Layout/etc. there's not much point to even using it library.

At that point, you can just write your own Javascript functions / classes for rendering, and handle your own state management

HTMX lends itself more to "sprinkling". Its basically just a very compact version of fetch(), combined with trigger logic (e.g. setTimeout(), onclick, etc.