Blog of Raivo Laanemets

Stories about web development, consulting and personal computers.

What React does not solve

On 2017-07-12

React goes a long way to provide a sane approach for building large-scale complex frontend solutions but it does not solve everything. One of such use cases is the manipulation of existing markup.

Sometimes I need to add some interactivity to server-generated HTML. For example, to implement inline form validation. The server-side HTML might be generated by an ExpressJS application or WordPress or just be a set of static HTML files. Majority of web sites actually work this way. The alternative approach is to generate HTML (or rather the DOM tree) on the client. This is what React and many other view libraries or frontend frameworks try to do.

React wants to generate and fully control your DOM. It has the JSX language extension to do it and a clever internal mechanism to make DOM interactions fast. However, it does not make much sense to use it for scripting the existing markup. This is the use case solved better with jQuery or nowadays with plain browser APIs if you do not target the old browsers. View libraries that bind to HTML are also a good choice here. Two of such libraries are Knockout and Vue.js.