3 ms·
People like to hate on the VDOM, but here's some food for thought: - VDOM is data-driven without side-effects - VDOM does not actually require JSX or build st
by mrozbarry 4y ago
People like to hate on the VDOM, but here's some food for thought:
- VDOM is data-driven without side-effects
- VDOM does not actually require JSX or build steps
- VDOM decouples you from the real dom, which has allowed things like react-native to "just work" the way react web works.
- VDOM means you can make test assertions without having to load up a "browser-like" environment
- JSON is a pretty easy to reason-about data structure, which makes debugging fairly easy
I'm not saying the virtual dom is the best answer, but I guess my point is that it's not really an issue of speed any more. If I recall my internet history, React came at a time when browser DOM standardization was still pretty wonky, so the virtual dom did provide a boost in manipulating the data that would translate to DOM mutations. Now that we're basically all running Chrome or Firefox under the hood (give or take webkit safari), I'm not sure that's the main drive any more, but the other benefits still stand, and that's why things like react are still using the virtual dom.
Anyway, cool library. I'm curious if it provides something that is actually different from other libraries I've used, in terms of interface or flow, and I might find some time to check it out soon. Good job!
- rektide 4y agoThe bottom half of this list doesnt seem remarkable to me. Smaller DOMs like Deno.DOM[1] or jsdom also can do that: we dont need a vdom to do that. [1] https://deno.land/manual@v1.25.4/jsx_dom/deno_dom https://deno.land/manual@v1.25.4/jsx_dom/deno_dom
- mrozbarry 4y agoOf course you don't need the vdom for testing, but it's typically a little lighter weight since the implementation of the vdom would already be bundled in. That said people typically reach for some special vdom assertion library anyway.