img

Introduction React Virtual DOM

2022-02-02

Keyboard with blue light

The modern web introduces a lot of new concepts. DOM (Document Object Model) manipulation is one of the main ways to enhance web experiences and interactivity. However, it decreases performance and speed more than most operations. React Virtual DOM comes in handy: a new concept to update your document structure without affecting performance, let's dive into it!

DOM dokument object model orange

The problem with DOM manipulation

Using the 'Document' object you can access an object's structure, in order to change the proprieties of any objects within the DOM tree. The main problem with DOM manipulation is when any object gets updated, the DOM tree gets rebuilt entirely to display the changes. That affects the speed, performance, and obviously user experience negatively. So how can we manipulate the DOM in a more efficient way?

react virtual dom and react logo

What is React Virtual Dom?

React.js introduces a new concept of DOM called Virtual DOM, a lightweight copy of each DOM object, which explains how React.js can deliver high-performing web apps. But how does this virtual Dom actually works?

How does Virtual DOM work?

When an object gets updated, React compare the Virtual DOM with the pre-update version, in order to figure out exactly which object has changed. In that way, React changes only the updated objects and leave the rest as it is. In other words, React Virtual DOM updates only the necessary part of the DOM tree.

Conclusion

As a React.js developer at Will & Skill, we really appreciate performance and speed. So we definitely appreciate React Virtual DOM. Any questions or suggestions? Get in touch by email or Instagram DMs.

Enjoyed this article? Consider sharing it.