How react works I'm new to reactjs I've been following this topic for the last 2 months, and got some information by googling about it,
React Web apps download all static assets and reactjs library to client at first reload, then React controls the actual DOM. React renders the DOM according to the state changes. React has a virtual DOM, which is a copy of real DOM which lives in memory, changing virtual DOM is less expensive, changing actual DOM is more expensive.
I got all these above information by reading different blogs, my questions are:
Please someone with good knowledge in React and its architecture helps me find out the answer.
chaging the actual dom is expensive, so why not store the images of dom in memory and update it according to where actually the dom got updated. virtual dom stores the whole app as an object and whenever there is a state change a new virtual dom object is created out of the previous one, then react does comparison of the previous to the new one using diffing algorithm. this overhead is not much expensive compared to just updating the browser dom directly on small changes.