We have a tree with app being the root or top level component and message being a child component when a application starts, react takes this component tree and builds
a JavaScript data structure called the virtual DOM (this virtual DOM is different from the actual DOM in the browser, it is a lightweight in memory representation) of our component tree where each node represents a component and its properties, when data of component tree changes react updates the corresponding node in the virtual DOM to reflect the new state then it compares the current version of virtual DOM to the previous version of DOM and identify the node that should be updated and then update the nodes in the actual DOM.
React was created to make it easier to build user interfaces for web applications. It simplifies the process of updating and managing the parts of a web page that change as a user interacts with it.
Imagine you're building a web page like a to-do list app. When a user adds a new item to their to-do list, you want the page to instantly show the new item without having to refresh the whole page. React helps you do this efficiently.
Before React, developers had to manually update the web page's HTML whenever something changed. With React, you describe how your user interface should look for different states, and React takes care of updating the page when those states change.
Top comments (0)