Rendering
Last updated
What is Rendering?
React follows a declarative approach to rendering components, which means that developers specify what a component should look like, and React takes care of rendering the component to the screen. This is in contrast to an imperative approach, where developers would write code to manually manipulate the DOM (Document Object Model) to update the UI.
The virtual DOM (VDOM) is an important aspect of how React works. It is a lightweight in-memory representation of the DOM (Document Object Model), and it is used to optimize the rendering of components in a React application.
- Components are written as JavaScript classes or functions that define a render method. The render method returns a description of what the component should look like, using JSX syntax.
- When a component is rendered, React creates a virtual DOM (VDOM) representation of the component. The VDOM is a lightweight in-memory representation of the DOM, and it is used to optimize the rendering of components.
- React compares the VDOM representation of the component with the previous VDOM representation (if it exists). If there are differences between the two VDOMs, React calculates the minimum number of DOM updates needed to bring the actual DOM into line with the new VDOM.
- React updates the actual DOM with the minimum number of DOM updates needed to reflect the changes in the VDOM.
This process is known as reconciliation, and it is an important aspect of how React works. By using a declarative approach and a VDOM, React is able to optimize the rendering of components and improve the performance of web applications.
Free resources to learn Rendering
- Official docsRender and Commit - Official Docs
- ArticleRendering in React - ui.dev
- ArticleFix the slow render before you fix the re-render
More in stage 3: Rendering
Rendering: common questions
Can I learn Rendering in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Rendering in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this Rendering tutorial for beginners?
It is lesson 4 of 79 in the free React roadmap, in stage 3, Rendering. If you are new to React, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.