Came across below statement in one or other form on google
Each time the underlying data changes in a React app, a new Virtual DOM representation of the user interface is created.This is where things get interesting. Updating the browser’s DOM is a three-step process in React.
Whenever anything may have changed, the entire UI will be re-rendered in a Virtual DOM representation.
The difference between the previous Virtual DOM representation and the new one will be calculated.
- The real DOM will be updated with what has actually changed. This is very much like applying a patch.
I am new to React and would like to understand above how above three points used to to work in pre-React Era say in jQuery (or native JS).
jQuery
- HTML was constructed on server side, sent back to browser. Browser will parse, render, layout and paint it.
- Say any new DOM element is created or hidden either on some user event or on load.
- Will jQuery recreate the complete DOM? From third point stated above looks like React just update the DOM for only the part that has been changed but other system (primarily jQuery or native JS) will recreate the complete DOM. Is that correct?
- Is the third point true only for DOM changes or even when state of any UI component changes like filling the text box/dropdown etc?