Home JavaScript React JSX and Rendering Elements
Beginner 6 min · July 13, 2026

React JSX and Rendering Elements

JSX syntax, embedding expressions, rendering elements, fragments, and the Virtual DOM..

N
Naren Founder & Principal Engineer

20+ years shipping production JavaScript and front-end systems at scale. Written from production experience, not tutorials.

Follow
Verified
production tested
July 13, 2026
last updated
2,018
articles · all by Naren
Before you start⏱ 36 min read
  • Basic JavaScript knowledge (variables, functions, objects), Node.js v18 or higher, npm v9 or higher, a code editor (VS Code recommended), familiarity with the command line.
Quick Answer

React JSX and Rendering Elements: A core React concept for building modern user interfaces. It helps you structure your components efficiently and handle data flow predictably.

✦ Definition~90s read
What is JSX and Rendering Elements?

React JSX and Rendering Elements is a fundamental concept in React development. It refers to the patterns, APIs, and best practices that React provides for building user interfaces. Understanding this concept is essential for writing clean, efficient, and maintainable React code. This tutorial covers everything from basic usage to advanced patterns with real-world examples.

React is a JavaScript library for building user interfaces.
Plain-English First

React is a JavaScript library for building user interfaces. This article covers jsx rendering — a key concept for building modern web applications.

⚙ Browser compatibility
Latest versions — ✓ supported
ChromeFirefoxSafariEdge

A comprehensive guide to react jsx and rendering elements with production examples and best practices.

What Is JSX?

JSX is a syntax extension for JavaScript that looks like HTML but compiles to React.createElement calls. It's not a template language—it's syntactic sugar that lets you describe UI structure declaratively. Under the hood, Babel transforms JSX into plain JavaScript objects called React elements. This means you can embed any JavaScript expression inside JSX using curly braces. JSX prevents injection attacks by default because React DOM escapes any values embedded before rendering. In production, always use the production build of React which skips prop type validation and other development warnings for better performance.

App.jsxJSX
1
2
const element = <h1>Hello, world!</h1>;
ReactDOM.createRoot(document.getElementById('root')).render(element);
Output
Renders an h1 element with text 'Hello, world!'
Try it live
🔥JSX is not HTML
JSX uses camelCase for attributes (e.g., className instead of class) and self-closing tags must have a slash (e.g., <img />).
📊 Production Insight
In production, ensure Babel is configured to strip development-only code like propTypes to reduce bundle size.
🎯 Key Takeaway
JSX is syntactic sugar for React.createElement, enabling declarative UI composition.
react-jsx-rendering THECODEFORGE.IO React JSX Rendering Process Step-by-step flow from JSX to DOM updates Write JSX HTML-like syntax in JavaScript Babel Transpilation JSX converted to React.createElement calls Create Virtual DOM Lightweight representation of UI ReactDOM.render Renders element into root container Diffing Algorithm Compares new and previous virtual DOM Update Real DOM Only necessary changes applied ⚠ Direct DOM manipulation bypasses React's diffing Always use ReactDOM.render for updates THECODEFORGE.IO
thecodeforge.io
React Jsx Rendering

Embedding Expressions in JSX

You can embed any JavaScript expression inside JSX by wrapping it in curly braces. This includes variables, function calls, and even JSX itself. However, statements (like if/else) are not allowed—use ternary operators or logical && instead. For arrays, JSX automatically joins them with no separator; use .join(', ') if you need commas. Be careful with falsy values like 0 or empty strings: they render as text. A common bug is rendering a count of 0 when the array is empty because 0 is falsy but React renders it. Always use conditional rendering explicitly.

ExpressionExample.jsxJSX
1
2
3
4
5
6
7
8
const user = { name: 'Alice', age: 30 };
const element = (
  <div>
    <h1>Hello, {user.name}!</h1>
    <p>You are {user.age} years old.</p>
    {user.age >= 18 && <p>You are an adult.</p>}
  </div>
);
Output
Renders a div with greeting, age, and conditional adult message.
Try it live
⚠ Falsy values render
Expressions like {0} or {''} render as '0' or empty string. Use {count > 0 && <p>Items: {count}</p>} to avoid showing '0'.
📊 Production Insight
A common production bug: rendering a list with {items.length && <List items={items} />} shows '0' when empty. Always use ternary or Boolean() to coerce.
🎯 Key Takeaway
Use {} for expressions; avoid statements and watch out for falsy rendering.

JSX Attributes and Styling

JSX attributes follow camelCase naming: className, htmlFor, onClick, etc. Inline styles are written as JavaScript objects with camelCase properties. For dynamic class names, use template literals or libraries like classnames. Avoid inline styles for production—they bypass CSS optimizations and increase specificity issues. Instead, use CSS modules or styled-components. Remember that style objects must have numeric values without units for most properties (React appends 'px' automatically for some properties, but not all—test it).

StylingExample.jsxJSX
1
2
3
4
5
6
const divStyle = {
  color: 'blue',
  backgroundColor: 'lightgray',
  padding: '10px',
};
const element = <div style={divStyle}>Styled div</div>;
Output
Renders a div with blue text, light gray background, and 10px padding.
Try it live
💡Use CSS classes over inline styles
Inline styles are fine for dynamic values, but prefer className for static styles to leverage CSS cascade and caching.
📊 Production Insight
In production, CSS-in-JS solutions can cause runtime overhead. For high-traffic apps, consider extracting critical CSS at build time.
🎯 Key Takeaway
Use camelCase for attributes and style objects; prefer className for static styles.
react-jsx-rendering THECODEFORGE.IO React JSX Rendering Architecture Layered stack from JSX to browser DOM Application Layer JSX Syntax | Embedded Expressions | Attributes and Styling Transpilation Layer Babel Compiler | React.createElement Virtual DOM Layer Element Tree | Diffing Algorithm Rendering Layer ReactDOM.render | Reconciliation Browser DOM Layer Real DOM Updates | Minimal Changes THECODEFORGE.IO
thecodeforge.io
React Jsx Rendering

Rendering Elements with ReactDOM

React elements are the smallest building blocks of React apps. To render an element into the DOM, use ReactDOM.createRoot() and call render(). The root DOM node is typically a single <div> in your HTML. React elements are immutable—once created, you cannot change its children or attributes. To update the UI, create a new element and pass it to render() again. React efficiently updates only the changed parts using its virtual DOM diffing algorithm. In production, always use the production build of React and ReactDOM to disable development warnings and enable performance optimizations.

index.jsxJSX
1
2
3
4
5
6
import React from 'react';
import ReactDOM from 'react-dom/client';

const element = <h1>Hello, world!</h1>;
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(element);
Output
Renders an h1 element inside the #root div.
Try it live
🔥Single root element
React 18's createRoot replaces ReactDOM.render. Only call createRoot once per app.
📊 Production Insight
In production, use the minified React build (react.production.min.js) to reduce bundle size and skip propTypes validation.
🎯 Key Takeaway
React elements are immutable; update UI by creating new elements and re-rendering.

Updating the Rendered Element

React elements are immutable, so to update the UI you create a new element and pass it to root.render(). React compares the new element with the previous one and applies minimal DOM updates. This is efficient for simple cases, but for complex UIs you'll use state management. A common mistake is calling render() multiple times on the same root—this is fine for learning but in production you should use components with state. The render() function is synchronous and blocks the browser until the DOM is updated.

Timer.jsxJSX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import React from 'react';
import ReactDOM from 'react-dom/client';

function tick() {
  const element = (
    <div>
      <h1>Hello, world!</h1>
      <h2>It is {new Date().toLocaleTimeString()}.</h2>
    </div>
  );
  root.render(element);
}

const root = ReactDOM.createRoot(document.getElementById('root'));
setInterval(tick, 1000);
Output
Updates the time every second.
Try it live
⚠ Avoid setInterval in real apps
This example is for illustration. In production, use useEffect with setTimeout or requestAnimationFrame for better control.
📊 Production Insight
Calling render() manually is rare in production—use state and setState inside components to trigger re-renders.
🎯 Key Takeaway
Update UI by calling render() with a new element; React diffs efficiently.

React Only Updates What's Necessary

React's virtual DOM diffing ensures that only the parts of the real DOM that changed are updated. Even if you re-render the entire tree, React compares the new virtual DOM with the previous snapshot and applies minimal patches. This makes React fast for most use cases. However, unnecessary re-renders can still cause performance issues. Use React.memo, useMemo, and useCallback to prevent wasteful re-renders in production. Also, avoid creating new objects or functions in render unless necessary, as they break referential equality.

DiffExample.jsxJSX
1
2
3
4
5
6
7
// Only the time text updates, not the entire div
const element = (
  <div>
    <h1>Hello, world!</h1>
    <h2>It is {new Date().toLocaleTimeString()}.</h2>
  </div>
);
Output
React updates only the h2 text node, leaving the h1 untouched.
Try it live
💡Keys in lists
When rendering lists, always provide a unique key prop to help React identify which items changed.
📊 Production Insight
In large lists, missing keys cause full re-renders. Always use stable IDs (not array index) as keys.
🎯 Key Takeaway
React updates only changed DOM nodes via virtual DOM diffing.

JSX Prevents Injection Attacks

By default, React DOM escapes any values embedded in JSX before rendering them. This means you cannot inject arbitrary HTML or scripts via user input. However, if you need to render raw HTML (e.g., from a CMS), use dangerouslySetInnerHTML—but only after sanitizing the input. Never use it with user-generated content. Cross-site scripting (XSS) vulnerabilities often arise from bypassing React's escaping. In production, always sanitize HTML with a library like DOMPurify before using dangerouslySetInnerHTML.

SafeHTML.jsxJSX
1
2
3
4
5
6
const userInput = '<script>alert("XSS")</script>';
const element = <div>{userInput}</div>; // Safe: renders as text

const html = '<strong>bold</strong>';
const sanitizedHtml = DOMPurify.sanitize(html);
const unsafeElement = <div dangerouslySetInnerHTML={{ __html: sanitizedHtml }} />;
Output
First div renders the script tag as text; second div renders bold text safely.
Try it live
⚠ dangerouslySetInnerHTML is dangerous
Only use it with sanitized content. Never trust user input directly.
📊 Production Insight
A common production vulnerability: using dangerouslySetInnerHTML with unsanitized data from APIs. Always sanitize server-side or with DOMPurify.
🎯 Key Takeaway
React escapes JSX values by default, preventing XSS; use dangerouslySetInnerHTML only with sanitized HTML.

JSX and Components

JSX is not limited to HTML tags—you can also render custom React components. Component names must start with a capital letter to distinguish them from HTML tags. Props are passed as JSX attributes and accessed as an object inside the component. Components can be functions or classes (though functions are preferred). In production, use functional components with hooks for better performance and simpler code. Avoid creating components inside render or other components—they cause unnecessary re-mounting.

ComponentExample.jsxJSX
1
2
3
4
5
6
7
function Welcome(props) {
  return <h1>Hello, {props.name}</h1>;
}

const element = <Welcome name="Sara" />;
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(element);
Output
Renders an h1 with 'Hello, Sara'.
Try it live
🔥Component names must be capitalized
Lowercase tags like <welcome> are treated as HTML elements, not components.
📊 Production Insight
In production, avoid defining components inside loops or conditionals—they cause state loss and performance issues.
🎯 Key Takeaway
Use capital letters for component names; pass data via props.

Composing Components with JSX

Components can be composed together to build complex UIs. JSX makes this natural: you can nest components just like HTML. Props flow downward from parent to child. This unidirectional data flow makes debugging easier. In production, keep components small and focused. Extract reusable UI pieces into separate components. Avoid deeply nested prop drilling—use context or state management libraries for global data. Also, remember that JSX expressions can include components, so you can conditionally render them.

Composition.jsxJSX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function Avatar(props) {
  return <img className="avatar" src={props.user.avatarUrl} alt={props.user.name} />;
}

function UserInfo(props) {
  return (
    <div className="user-info">
      <Avatar user={props.user} />
      <div className="user-name">{props.user.name}</div>
    </div>
  );
}

function App() {
  const user = { name: 'Alice', avatarUrl: 'https://example.com/avatar.png' };
  return <UserInfo user={user} />;
}
Output
Renders a user info card with avatar and name.
Try it live
💡Extract components early
If a component grows too large, split it into smaller components. This improves reusability and testability.
📊 Production Insight
In large apps, prop drilling becomes painful. Use React Context or Zustand for shared state to avoid passing props through many layers.
🎯 Key Takeaway
Compose components by nesting JSX; props flow downward.

JSX and the Virtual DOM

JSX is compiled to React.createElement calls, which produce plain JavaScript objects called React elements. These elements form a virtual DOM tree. When state changes, React creates a new virtual DOM tree and diffs it against the previous one. The diffing algorithm (reconciliation) determines the minimal set of DOM mutations. Understanding this helps you write efficient code. For example, using a stable key prop on list items helps React reuse DOM nodes. In production, avoid mutating state directly—always use setState or useState updater functions to trigger proper reconciliation.

VirtualDOM.jsxJSX
1
2
3
4
5
// JSX
const element = <div className="container">Hello</div>;

// Compiled to
const element = React.createElement('div', { className: 'container' }, 'Hello');
Output
Both produce the same React element object.
Try it live
🔥Reconciliation is key
React's diffing algorithm assumes that elements of different types produce different trees. Use this to your advantage by changing component types to reset state.
📊 Production Insight
In production, avoid creating new component types on every render (e.g., inside a loop) as it forces React to unmount and remount, losing state.
🎯 Key Takeaway
JSX compiles to React.createElement; virtual DOM diffing enables efficient updates.

Production Best Practices for JSX

When deploying a React app, always use the production build. This minifies code, strips out development warnings, and enables performance optimizations like the production version of React. Use tools like Create React App, Vite, or Next.js which handle this automatically. For custom setups, set NODE_ENV=production and use TerserPlugin. Also, consider using React.lazy and Suspense for code splitting. Avoid large JSX trees in a single component—split them. Use ESLint with the react-plugin to catch common mistakes like missing keys or dangerous patterns.

build.shBASH
1
2
3
4
5
6
7
# For Create React App
npm run build

# For Vite
npm run build

# Output is in build/ or dist/ folder
Output
Produces optimized static files ready for deployment.
⚠ Never use development build in production
Development builds include extra warnings and are slower. They also expose internal React details that can be exploited.
📊 Production Insight
A common production mistake: forgetting to set NODE_ENV=production, causing React to run in development mode with performance penalties and security risks.
🎯 Key Takeaway
Always use production builds; minify, code-split, and lint your JSX.

Common JSX Pitfalls and How to Avoid Them

Newcomers often trip over several JSX quirks. First, JSX requires a single root element—use fragments (<></>) to avoid extra divs. Second, comments must be inside curly braces: {/ comment /}. Third, self-closing tags like <img /> must have a slash. Fourth, conditional rendering using && can render 0 or NaN—use ternary or Boolean(). Fifth, spread attributes ({...props}) can override explicit props—order matters. In production, these bugs cause subtle UI issues. Always test edge cases like empty arrays or null values.

Pitfalls.jsxJSX
1
2
3
4
5
6
7
8
9
10
11
// Correct: fragment
return <><h1>Title</h1><p>Body</p></>;

// Correct: comment
{/* This is a comment */}

// Correct: conditional
{items.length > 0 && <List items={items} />}

// Wrong: renders '0' when empty
{items.length && <List items={items} />}
Output
First three are correct; last one renders '0' when items is empty.
Try it live
⚠ Watch out for falsy values
Expressions like {0} or {NaN} render as text. Always use explicit conditions.
📊 Production Insight
In production, a missing key prop on list items can cause incorrect DOM updates and accessibility issues. Always lint for missing keys.
🎯 Key Takeaway
Use fragments, proper comments, and explicit conditions to avoid common JSX bugs.

How JSX Compiles: Classic vs Automatic Runtime

JSX is not valid JavaScript; it must be compiled into JavaScript function calls. React traditionally uses React.createElement to transform JSX into elements. However, starting with React 17, a new JSX transform was introduced that uses jsx() and jsxs() from react/jsx-runtime, eliminating the need to import React in every file.

Classic Runtime (React.createElement) In the classic transform, JSX like <h1>Hello</h1> compiles to React.createElement('h1', null, 'Hello'). This requires import React from 'react' in every file that uses JSX.

Automatic Runtime (jsx() transform) With the automatic runtime, the same JSX compiles to import { jsx as _jsx } from 'react/jsx-runtime'; _jsx('h1', { children: 'Hello' }). This transform is enabled by setting "runtime": "automatic" in Babel or TypeScript config. It automatically imports the necessary functions, so you no longer need to import React just for JSX.

Key Differences - The automatic runtime produces slightly smaller bundles because it doesn't include the entire React object. - The automatic runtime supports fragment shorthand (<></>) without explicit import. - The classic runtime is still supported for backward compatibility.

To switch to automatic runtime, update your Babel config: ``json { "presets": [ ["@babel/preset-react", { "runtime": "automatic" }] ] } ` Or for TypeScript, set "jsx": "react-jsx" in tsconfig.json`.

Understanding the compilation helps debug issues like missing imports or unexpected behavior when upgrading React versions.

jsx-compile-example.jsJAVASCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
// Classic Runtime
// Input JSX
const element = <h1>Hello</h1>;
// Compiled output
const element = React.createElement('h1', null, 'Hello');

// Automatic Runtime
// Input JSX
const element = <h1>Hello</h1>;
// Compiled output
import { jsx as _jsx } from 'react/jsx-runtime';
const element = _jsx('h1', { children: 'Hello' });
Try it live
🔥Automatic Runtime is the Default in React 17+
📊 Production Insight
In production, the automatic runtime can reduce bundle size by up to 2KB gzipped because it avoids including the entire React object. Use the automatic transform in your build configuration to optimize performance.
🎯 Key Takeaway
React's JSX transform has two modes: classic (React.createElement) and automatic (jsx/jsxs). The automatic runtime is recommended for new projects as it reduces boilerplate and bundle size.

JSX Converter Tools

When migrating existing HTML markup to React, manually converting HTML to JSX can be tedious. JSX converter tools automate this process by transforming HTML strings into valid JSX syntax, handling attribute changes (e.g., class to className, for to htmlFor), self-closing tags, and inline styles.

Popular Tools - HTML to JSX (https://htmltojsx.com/): A web-based converter that instantly converts HTML snippets to JSX. It handles most common transformations and allows copying the result. - Babel Plugin: The @babel/plugin-transform-react-jsx can be used with a custom pragma to convert HTML-like syntax, but it's more complex. - VS Code Extensions: Extensions like "HTML to JSX" provide in-editor conversion, useful for large codebases.

Example Conversion Input HTML: ``html <div class="container" id="main"> <p style="color: red;">Hello World</p> </div> ` Output JSX: `jsx <div className="container" id="main"> <p style={{ color: 'red' }}>Hello World</p> </div> ``

Limitations - Inline event handlers (e.g., onclick) are not automatically converted to React events. - Complex HTML structures may require manual adjustment for React components. - Tools may not handle all edge cases, so always review the output.

Using converter tools accelerates migration of static HTML to React components, especially when dealing with large templates from design systems or legacy code.

html-to-jsx-example.jsJSX
1
2
3
4
5
6
7
8
9
10
11
12
13
// Before (HTML)
const html = `<div class="card">
  <img src="logo.png" alt="Logo">
  <h2>Title</h2>
</div>`;

// After (JSX) using converter
const element = (
  <div className="card">
    <img src="logo.png" alt="Logo" />
    <h2>Title</h2>
  </div>
);
Try it live
💡Always Validate Converted JSX
📊 Production Insight
In production, use converter tools as a one-time migration aid. For ongoing development, rely on linting rules (e.g., eslint-plugin-react) to enforce JSX correctness rather than repeated conversion.
🎯 Key Takeaway
JSX converter tools like HTMLtoJSX.com simplify migrating HTML to React by automatically adjusting attribute names and syntax, but manual review is still necessary for event handlers and complex structures.
JSX vs Plain JavaScript Rendering Comparing syntax, security, and performance JSX Plain JavaScript Syntax HTML-like declarative syntax Imperative createElement calls Readability High for UI structures Lower due to nested calls Injection Protection Automatic escaping of expressions Manual sanitization required Performance Virtual DOM diffing for updates Direct DOM manipulation Tooling Support Babel transpilation needed No transpilation required THECODEFORGE.IO
thecodeforge.io
React Jsx Rendering

Keyed Fragments

When rendering lists in React, each element should have a unique key prop for efficient reconciliation. However, when using fragments (<></> or <Fragment>), you cannot directly add a key to the shorthand syntax. Instead, use the explicit <Fragment key={id}> pattern to assign keys to fragments.

Why Keyed Fragments? Sometimes you need to render multiple sibling elements without a wrapper div, but still need a key for each item in a list. For example, rendering a list of items where each item consists of multiple elements (e.g., a row with multiple columns). Using a keyed fragment allows React to track each group efficiently.

Example ```jsx import React, { Fragment } from 'react';

function ItemList({ items }) { return ( <div> {items.map(item => ( <Fragment key={item.id}> <h2>{item.title}</h2> <p>{item.description}</p> </Fragment> ))} </div> ); } ```

Important Notes - The shorthand <></> does not support keys; you must use <Fragment>. - Keys should be unique among siblings, just like with regular elements. - Keyed fragments are particularly useful when you cannot add a wrapper div due to CSS or layout constraints.

Performance Impact Using keyed fragments helps React's diffing algorithm identify which items changed, added, or removed, leading to more efficient updates. Without keys, React may re-render all items unnecessarily.

Always use stable, unique identifiers (like database IDs) for keys, not array indices, to avoid rendering bugs.

keyed-fragments-example.jsxJSX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import React, { Fragment } from 'react';

function BlogPosts({ posts }) {
  return (
    <div>
      {posts.map(post => (
        <Fragment key={post.slug}>
          <h2>{post.title}</h2>
          <p>{post.excerpt}</p>
          <hr />
        </Fragment>
      ))}
    </div>
  );
}
Try it live
⚠ Shorthand Fragments Don't Accept Keys
📊 Production Insight
In production, keyed fragments are essential for list performance. Use stable IDs as keys to minimize re-renders and avoid UI flickering. Profile your app with React DevTools to verify key usage.
🎯 Key Takeaway
Use explicit <Fragment key={id}> to assign keys to fragment groups in lists, enabling efficient reconciliation without adding extra DOM nodes.
⚙ Quick Reference
15 commands from this guide
FileCommand / CodePurpose
App.jsxconst element =

Hello, world!

;
What Is JSX?
ExpressionExample.jsxconst user = { name: 'Alice', age: 30 };Embedding Expressions in JSX
StylingExample.jsxconst divStyle = {JSX Attributes and Styling
index.jsxconst element =

Hello, world!

;
Rendering Elements with ReactDOM
Timer.jsxfunction tick() {Updating the Rendered Element
DiffExample.jsxconst element = (React Only Updates What's Necessary
SafeHTML.jsxconst userInput = '';JSX Prevents Injection Attacks
ComponentExample.jsxfunction Welcome(props) {JSX and Components
Composition.jsxfunction Avatar(props) {Composing Components with JSX
VirtualDOM.jsxconst element =
Hello
;
JSX and the Virtual DOM
build.shnpm run buildProduction Best Practices for JSX
Pitfalls.jsxreturn <>

Title

Body

;
Common JSX Pitfalls and How to Avoid Them
jsx-compile-example.jsconst element =

Hello

;
How JSX Compiles
html-to-jsx-example.jsconst html = `
JSX Converter Tools
keyed-fragments-example.jsxfunction BlogPosts({ posts }) {Keyed Fragments

Key takeaways

1
JSX is syntactic sugar
It compiles to React.createElement calls, enabling declarative UI composition.
2
React elements are immutable
To update the UI, create new elements and re-render; React diffs efficiently.
3
JSX prevents XSS by default
Values are escaped; use dangerouslySetInnerHTML only with sanitized HTML.
4
Production builds are essential
Always use minified React builds and set NODE_ENV=production for performance and security.

Common mistakes to avoid

3 patterns
×

Not understanding React component re-rendering

Fix
Use React.memo, useMemo, and useCallback strategically to prevent unnecessary re-renders.
×

Ignoring the rules of hooks

Fix
Always call hooks at the top level, not inside conditions, loops, or callbacks.
×

Mutating state directly instead of using setState

Fix
Always use the state setter function and treat state as immutable.
INTERVIEW PREP · PRACTICE MODE

Interview Questions on This Topic

Q01JUNIOR
What is the Virtual DOM and how does React use it?
Q02JUNIOR
Explain the difference between state and props.
Q03JUNIOR
What is the purpose of the useEffect hook?
Q04JUNIOR
How does React handle keys in lists?
Q01 of 04JUNIOR

What is the Virtual DOM and how does React use it?

ANSWER
The Virtual DOM is a lightweight JavaScript representation of the real DOM. React diffs the Virtual DOM with the previous version and applies only the changed parts to the real DOM.
FAQ · 6 QUESTIONS

Frequently Asked Questions

01
What is JSX and why is it used?
02
Can I use JavaScript expressions inside JSX?
03
How does React update the DOM when using JSX?
04
What is the difference between JSX and HTML?
05
How do I prevent XSS attacks when using JSX?
06
Why should I avoid using array index as key in lists?
N
Naren Founder & Principal Engineer

20+ years shipping production JavaScript and front-end systems at scale. Written from production experience, not tutorials.

Follow
Verified
production tested
July 13, 2026
last updated
2,018
articles · all by Naren
🔥

That's React. Mark it forged?

6 min read · try the examples if you haven't

Previous
Introduction to React
14 / 40 · React
Next
React Components and Props