☕ 3 min read

Why React Sticks with Virtual DOM: My Thoughts


I’ve been seeing a lot of discussions lately about React’s Virtual DOM approach, especially compared to newer frameworks using signals. Let’s chat about why React’s choices make sense, even in 2024.

The Simple Truth About React’s Approach

React still chooses Virtual DOM? It’s not that it’s old-fashioned - it’s more like React chose a different path than other frameworks, and for some pretty good reasons! The React team has always prioritized making things predictable and easy to understand, even if that means trading off a bit of raw performance.

Let’s Compare Approaches

Signals

Think of signals (used in Solid.js and Preact) like smart sensors that know exactly what needs to be updated. When something changes, only the parts of your app that actually care about that change will update. Pretty neat, right?

React’s Way: Virtual DOM

React takes a different approach. It treats your components like pure functions - give them the same input, and you’ll always get the same output. When something changes, React:

— Creates a new version of your component tree

— Compares it with the old version

— Updates only what’s necessary

While this might not be the fastest approach, it gives us some really nice benefits:

— It’s super easy to understand (just think “my state changes → my UI updates”)

— Debugging is a breeze (you can actually see what React is thinking about rendering)

— Your app behaves predictably (components always render the same way)

But Isn’t React Slow?

I hear this a lot, and honestly, it’s not that simple! While yes, fine-grained reactivity can be faster, here’s the reality:

— React is plenty fast for most apps we build

— The React team keeps making things better (like automatic batching)

— They’re working on a cool new compiler that could make things even faster

Why Not Just Switch to Signals?

Here’s the thing - switching to signals would be like rebuilding a house from the ground up. It would:

— Break lots of existing React apps

— Require the whole React ecosystem to change

— Force all of us to learn a completely new way of thinking about our apps

Instead, the React team is making smart improvements to what we already have, while looking for ways to get some of those signal-like benefits without turning everything upside down.

The Bottom Line

Sure, some developers get excited about newer approaches (and that’s great!). But React’s focus on stability and backwards compatibility is what makes it such a reliable choice for companies big and small. It’s like that dependable friend who might not be the flashiest but always has your back.

React might not be the best in terms of performance, but it’s still evolving in its own way, focusing on what it does best - helping us build predictable, maintainable applications.

I like to explore

But as I play around with Solid, Svelte and Preact, they are absolute wonders to work with. I look forward to working with one of them in production as well, especially Svelte 5 with Runes. Because I thought every variable we declare being reactive was not a good idea when they were in version 4.