9 ms·
“do I need a component library?” is the question I ask when deciding to use react or not. It’s a totally different question to ask do I need a spa or a server
by potench 8y ago
“do I need a component library?” is the question I ask when deciding to use react or not.
It’s a totally different question to ask do I need a spa or a server rendered app, both can be dead simple or heinously complex or reasoned away to prove a point...
I 100% of the time want (1) to architect my UI as a collection of atomic, reusable components, (2) get page specific server rendered html per route, and (3) do JS in a sane way (manipulate DOM, manage client state, and support a series of interactions that do not reload the page.)
So, what are my options?
1. React/node
2. Sacrifice one of the above.
- brylie 8y agoI think all of your requirements could be met in a myriad of ways. E.g. Django templates/Handlebars can be organized as reusable components, many backend frameworks will render HTML per route, and there are several JavaScript client libraries including Vue and, dare I say, jQuery that will give you a sane way to do client interactivity without page refresh with varying degrees of declarative code style.
- potench 8y agoI think this means you are sacrificing the component library requirement. There is not a sane way to intermix js,html,css as a single component with dependencies on other components with your approach. What you end up with is 3 very distinct/separate/unique/difficult to maintain solutions across css, js (probably 4 if you include js/html), html.
- brylie 8y agoVue.js and Aurelia offer examples of how UI components can be organized and composed, while allowing clean separation of structure, function, and presentation (divided along the lines of HTML, JavaScript, and CSS by design.) The main point is not to limit ourselves to a monotheistic worldview that convinces us, without substantive evidence, that "all other ways are wrong."
- potench 8y agoThe main point is that I listed 3 requirements/wants. Your example of Vue.js or Aurelia sacrifices the requirement for server-rendering. > Server Side Rendering is a new feature of the Aurelia framework, intended for use by early adopters. https://aurelia.io/docs/ssr/introduction#how-it-works https://aurelia.io/docs/ssr/introduction#how-it-works
- crooked-v 8y agoFor (2), take a look at Next.js. It's a React SSR framework, but there's a static build option that turns every page into prerendered HTML files with embedded JS at build time.