Menu

Post image 1
Post image 2
Post image 3
Post image 4
Post image 5
Post image 6
Post image 7
Post image 8
1 / 8
0

Virtual Dom Explained in React

DEV Community·Manmeet Singh·27 days ago
#9kYc6RL5
Reading 0:00
15s threshold

When we start learning JavaScript, we often come across a concept known as DOM (Document Object Model). We know that browsers use the DOM to render content on the screen. But let me ask you a question? If you had to change something on the webpage, let's say colour of a button, would you destroy the entire DOM and rebuild it again from scratch? Technically, you could. In fact, traditional web applications often worked in ways that caused large parts of the page to re-render frequently. But think about how expensive that operation is. Destroying and rebuilding DOM nodes is not cheap because the browser has to: Recalculate styles Recompute layout positions Repaint pixels on the screen Potentially trigger reflows for surrounding elements For small hobby projects like a simple Todo app, this usually isn't a big problem. But imagine large-scale applications like social media platforms or travel booking websites.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More