I am trying to learn the general concept of virtual dom in React.
My assumption is as follows:
React uses virtual DOM to enhance performance. Virtual dom is a lightweight copy of the real DOM stored in memory. When there is a change of state or prop, React creates a virtual DOM. It uses the diffing algorithm to compare the previous virtual DOM with the updated virtual DOM. Lastly, it performs a process called reconciliation to determine which part of the real DOM needs to be updated and update it.
Here are a few questions that I have:
Does React has two Virtual DOMs? When I google, it said React only has 1 virtual DOM. So after it compares the previous virtual DOM with the updated virtual DOM, React automatically deletes the previous virtual DOM?
Another article I found online here says that the diffing algorithm is the comparison of the real DOM with virtual DOM. So I am confused because many articles on google said diffing algorithm is the comparison of the previous virtual DOM and the updated virtual DOM.