DEV Community

Discussion on: The future of the web: navigating HTMX, vanilla JS, and React

Collapse
 
webjose profile image
José Pablo Ramírez Vargas

If the response is an object with the likes property, how does HTMX know to read this property? Is the sample incomplete?

Collapse
 
brense profile image
Rense Bakker

Yes it is. It also needs to go to a server for each user click 😛

Collapse
 
pashadia profile image
pashadia

.... as opposed to updating the likes counter without going to the server?

If you were actually referring to building stateful SPAs, where not everything needs a server round-trip, here's how to do it, from the creator of htmx himself. There are also plenty of posts about combining htmx and react on the web.

Collapse
 
itarrant profile image
Iain

HTMX works by receiving a html string as a response and replacing/ swapping the matching CSS selector in the dom. In this case the innerHTML of the #like-counter.
This is if course only a simple example and much more elaborate things can also be done.

Collapse
 
webjose profile image
José Pablo Ramírez Vargas

Thanks. I don't debate HTMX's abilities. I just wanted to put out there that the article seems to have an intention to mislead readers making them think the code snippets presented produce equal/equivalent results. They don't.