React is an open-source, component-driven JavaScript library created by Meta for architecting scalable, high-performance user interfaces. Rather than imperatively manipulating the browser's Document Object Model (DOM) using manual methods like document.createElement or element.appendChild, React introduces a declarative programming model: you describe what the user interface should look like for a given state, and React automatically computes the most efficient way to update the browser's view.
At the core of React's architectural engine lies the Virtual DOM (VDOM) and the Fiber Reconciler:
{ type: 'h1', props: { children: 'Hello' } }.[ Component State Change ] ββ> [ Virtual DOM Re-render ]
β
βΌ (Fiber Diffing Algorithm)
[ Real Browser DOM ] <ββ (Commit Phase) ββ [ Minimal DOM Mutations ]---
Modern React applications are built using Functional Components rendered into an application root via the react-dom/client module:
import React from 'react';
import ReactDOM from 'react-dom/client';
// 1. Functional Component Definition
function Greeting({ name }) {
return <h1 className="greeting-title">Hello, {name}!</h1>;
}
// 2. Client Root Mounting (React 18 / 19 API)
const container = document.getElementById('root');
const root = ReactDOM.createRoot(container);
// 3. Declarative Tree Rendering
root.render(<Greeting name="React Developer" />);Key rules of the React rendering architecture:
props.---
In production web apps, components encapsulate markup, styling classes, and dynamic data:
function UserStatusBadge({ username, role, isOnline }) {
return (
<div className="flex items-center gap-3 p-4 bg-slate-900 rounded-xl border border-slate-800">
<div className={`w-3 h-3 rounded-full ${isOnline ? 'bg-emerald-500' : 'bg-slate-600'}`} />
<div>
<h4 className="text-sm font-semibold text-white">{username}</h4>
<span className="text-xs font-mono text-cyan-400">{role.toUpperCase()}</span>
</div>
</div>
);
}---
document.getElementById mutations inside React components. Let React own the DOM lifecycle.Greeting, not greeting). Lowercase tags are treated by JSX as native HTML tags (<div>, <span>).<> ... </>).---
In the myApp.js or script.js editor:
Greeting that accepts props and extracts name (e.g. function Greeting({ name }) or function Greeting(props)).<h1> tag displaying: <h1>Hello, {name}!</h1> (or props.name).ReactDOM.createRoot(document.getElementById("root")).root.render(<Greeting name="React Developer" />) to render the component.Hello, React Developer!