DEV Community

Discussion on: Virtual DOM in react

Collapse
 
grahamthedev profile image
GrahamTheDev

Suppose there is a list of four items, and you removed an item or added one, then in real DOM the entire document will be recreated.

I am a little confused, what are we comparing React to in this post? Is this a comparison to an old framework or something as this shouldn't be true in most circumstances.

For example with vanilla JS you would just do document.querySelector('li').remove(); to remove the first list item - that is essentially what React is doing, but after it has diffed the document to work out that is what needs doing.

There is no need to repaint the whole document in any framework I have ever seen, certainly not in vanilla JS?

Collapse
 
aasthapandey profile image
Aastha Pandey

Hi! actually you're right, I re-read my post and got the mistake.
Thanks for pointing it out.