3 ms·
> But what has [virtual DOM] got to do with reactive programming? Or embedding markup in JavaScript? It makes it possible to implement React's componentisation
by insin 12y ago
> But what has [virtual DOM] got to do with reactive programming? Or embedding markup in JavaScript?
It makes it possible to implement React's componentisation model in a performant manner.
It allows React to not only work in all major browsers today, but to use its SyntheticEvent implementation to patch up and normalise aspects of their behaviour which are important when writing webapps.
While React's ideas about data flow might not be new, the componentisation model it uses to implement them makes it incredibly easy to compose and reuse UI components, with a well-defined method of passing data between them and controlling re-rendering.
It allows React components to be easily pre-rendered on the server and rehydrated to be interactive on the client from the initial markup using the same codebase, making progressive enhancement easier to implement, therefore more likely to be implemented.
That's why the virtual DOM isn't the most interesting thing about React, rather what it enables.
It would be nice if native Web Components just worked everywhere right now, but they don't. Maybe some day React will just another way to implement the innards of a native Web Component, but at the moment it's just better then them.