I am trying to understand when to use the virtual DOM concept and when not to. After reading the following answer on SO (https://stackoverflow.com/a/28199479/4584825) I have got an impression that the virtual DOM is to be used only when we want to refresh the entire DOM tree. Is that true ?
Because take the following code snippet-:
<html>
<body>
<div id="a">Hello</div>
</body>
</html>
Now if I want to replace the content of the div
with say World. I would write something like-:
document.getElementById("a").innerHTML = World;
In this mirrors typical AJAX scenarios where only part of the page is refreshed. How would the virtual DOM help me in this case ? Anyways I am targeting a specific element or set of elements, so what difference does it make that whether I am using a virtual DOM or the real DOM ?