Earlier quoted context omitted.
How errors are handled is often pretty specific to each use case. Sometimes it does make sense to send back an HTML fragment with an inline error message, or a fragment that gets injected as a toast notification. Other times you may want to redirect to an error page with a full page refresh. Depending on the HTTP request method used, you may be able to return an HTTP error response too.
Absolutely. My point is that most or almost all HTMX examples/tutorials/tests show no error handling at all. Sooner or later you need to handle these different errors, and I don't think HTMX has these sort of "non-happy" paths at mind.
Htmx vs. React: A Complete Comparison – Semaphore
81–88 of 88 posts
Re: Htmx vs. React: A Complete Comparison – Semaphore
#82I think the list of features says it all. They're not exactly comparable, are they? I don't think there's even anything preventing you from using both with e.g. React on the backend and Htmx on the frontend to load in the HTML that React generates.
React on the backend + HTMX on the frontend would be hilarious. Someone should write a tutorial on this pretending to be serious.
Re: Htmx vs. React: A Complete Comparison – Semaphore
#83We've been using Turbo for over a year now (similar idea to Htmx). Pretty happy not to be using React anymore. Most of the complexity is offloaded to the backend where we can handle it better with a typed language system and no middle layer (e.g. GraphQL) between our app and the database. TypeScript is not typed fwiw, e.g. `as any`.
What about the empty interface type in Go?[0] Is that just as problematic for you? [0] https://go.dev/tour/methods/14
Re: Htmx vs. React: A Complete Comparison – Semaphore
#84Earlier quoted context omitted.
Now imagine how bad pre-react era frameworks were if the main selling point of React was “your SPA is now easier to reason about”.
That was a selling point of all the prior (and subsequent) frameworks as well. In fact, that's the selling point of htmx over react too. Opinions vary about how well any of these things achieve that objective.
Re: Htmx vs. React: A Complete Comparison – Semaphore
#85Earlier quoted context omitted.
I did also, many coming from classic programming that hasn't touched upon functional ways of thinking usually struggle since they're prone to shortcuts whereas React really likes you to keep everything as transformations (or as some would call it functional style). Much React work these days is confined into components, people sadly over-do it also because they perceived Redux as overkill and try to shoehorn entire a…
Transforming mutations into react-compatible object creation is not always trivial, particularly with twisty object graphs. I once spent a week trying to untangle a reducer monstrosity that wished it could mutate. In the end, I don't think I totally fixed it. It can be hard.
Joking aside, you're right, often it's almost easier in recursive cases to just go with flat object lists and keeping identities on objects and keep parent id's around.
In my view, React is a theoretically beautiful piece of software, and if you're planning on building a synchronized networked system keeping in line with what makes it beautiful will give you it almost for free.
For many practical cases (especially smaller SPA's/pages) however it's probably better to just go with Vue or similar and mutate away and let the system handle all update checks for you instead.
Re: Htmx vs. React: A Complete Comparison – Semaphore
#86React weight 6.4 kB? In which universe? React-dom alone is 42kB gzip. https://bundlephobia.com/package/react-dom
Preact is 3kb and works as a drop in replacement for React (most of the time). It's also way faster.
Re: Htmx vs. React: A Complete Comparison – Semaphore
#87Earlier quoted context omitted.
That was a selling point of all the prior (and subsequent) frameworks as well. In fact, that's the selling point of htmx over react too. Opinions vary about how well any of these things achieve that objective.
Before switching to React in 2015 I worked with ExtJS and Backbone, and both of them were much harder to reason about. Oh, and GWT too, that was a nightmare.
Re: Htmx vs. React: A Complete Comparison – Semaphore
#88HTMX relying on a server request to make even minor UI changes (e.g. their first example https://htmx.org/examples/click-to-edit/ ) is wild to me. You might remember when a thing called DHTML revolutionized how JavaScript could be used to build interactive UIs on the web... why go back to pre-2001 era? I get it, SPAs are overkill, but swinging the pendulum all the way back is very strange.
You might find https://data-star.dev/ interesting, it takes some of the modern approaches (signals, etc) and mixes it with the efficiency of sending straight-up HTML, htmx style. It's very similar to using Alpine + htmx together.