Render > Reconciliation > React

UI Engineer @Flipkart I like to explore new technologies & build projects on them.
Search for a command to run...

UI Engineer @Flipkart I like to explore new technologies & build projects on them.
Great Explanation
Well Explained! Started with a basic easy to understand explanation and ended with good visual examples.
Hey Sudip, loved your explanation! The visual element really help to vizualize things. Looking forward to more amazing content from your end!
Let's enable infinite scroll for virtual scrollbars

Event Bubbling, Event Capturing, Event Delegation

Introduction Javascript is a single-threaded interpreted language with a non-blocking event loop. What this means is that everything runs on a single main thread so it's important to use the thread only when required. Blocking this main thread means ...

One of the reasons React is so popular is that it's blazing fast. This speed is achieved by updating only part of the real DOM that has changed. But, updating the real DOM is a slow process. So, how does React achieve this? React achieves this using virtual DOM.
Virtual DOM is a lighter version of real DOM. But, it looks nowhere like the real DOM instead it's a tree of React(JS) objects that represent the UI at an instant.
Think of the real DOM as a building and virtual DOM as a blueprint of the building.
When a state changes or prop updates, it triggers a render.
When we hear the term "render" we think of it as painting a picture or printing a page. However, in React this is not what "render" means!
This is a process of traversing through the virtual DOM and collecting the updated states or props and running the render() function for those components which use the updated state or prop and create the new virtual DOM.
This process involves comparing the new virtual DOM with the old virtual DOM and finding the differences. This process is called reconciliation and it uses a diffing algorithm based on two assumptions:-
Due to the 2nd assumption, you might have seen Warning: Each child in a list should have a unique "key" prop many times. Now you know why this happens.
We'll look into what the 1st assumption means in the example given later.
Once React finds the most efficient way to update the UI, the real DOM gets updated. This is called a React phase or Commit phase (not render phase).
Throughout this example, the UI will remain the same, only the code will change.





So, what's happened here is, the same that happened in Part 3. On clicking Toggle Style a new component gets rendered and hence all of its children get rendered freshly.
In case, we need to make the counter retain its state then we may use context
The way React sees while diffing:
This was my understanding of Render Reconciliation React.