This episode dissects what happens inside React: the Virtual DOM, reconciliation, the render cycle, the commit phase, and the React Fiber architecture. You'll also learn about function components, props, state, lifecycle, one-way data flow, and the role of hooks as the core API.

In episode 1 you learned why React exists. Now it's time to see how it works behind the scenes. Concepts that sound technical — the Virtual DOM, reconciliation, the render cycle, React Fiber — are actually simple once you understand them in order.
Episode 2 dissects React's main architecture and introduces the core components you'll use every day: function components, props, state, one-way data flow, and hooks. This is the most important foundational episode; the entire series is built on the concepts covered here.
The Virtual DOM is a JavaScript representation of the UI structure. When you write JSX, React turns it into descriptive objects instead of directly manipulating the browser DOM. When state changes, React creates a new virtual tree and then compares it with the old tree — this process is called reconciliation:
state berubah
-> render pohon virtual baru
-> diff dengan pohon sebelumnya
-> tentukan perubahan minimum
-> patch DOM nyataThe reason for using this intermediate step is simple: creating and comparing JavaScript objects is far cheaper than touching the browser DOM, and the end result is minimal DOM changes.
React's rendering process is split into two major phases:
Understanding these two phases helps you avoid bugs: don't read or mutate the DOM during the render phase, because the results can be inconsistent.
JSX is HTML-like syntax written inside JavaScript. Browsers don't understand JSX, so Babel (via the Vite toolchain) transforms it into React.createElement function calls. The bundler then combines all the JavaScript modules into files the browser can load.
const elemen = <h1>Halo, React</h1>
// hasil transformasi Babel:
const elemen = React.createElement("h1", null, "Halo, React")The code const elemen = <h1>Halo, React</h1> is written by you; the transformation into React.createElement is handled automatically by the build tool. You don't need to call React.createElement manually in modern React.
React Fiber is the new reconciliation algorithm introduced in React 16. The core idea: rendering can be split into small units of work (fibers) that can be interrupted and prioritized. That's what paved the way for concurrent rendering — React can pause a non-urgent render to handle more pressing user interactions, keeping the UI responsive. We'll cover its stable patterns in episode 23.
Modern React recommends function components. The only significant difference from class components is how they manage state and lifecycle — classes use this.state and lifecycle methods, functions use hooks:
function Counter() {
const [jumlah, setJumlah] = React.useState(0)
return <button onClick={() => setJumlah(jumlah + 1)}>{jumlah}</button>
}Function components are more concise, don't use this, and const [jumlah, setJumlah] = React.useState(0) is the most common example of the useState hook. Class components are still valid but are no longer the first choice.
useEffect.function Kartu({ judul }) {
const [dibuka, setDibuka] = React.useState(false)
return (
<div>
<h3>{judul}</h3>
{dibuka ? <p>Konten kartu</p> : null}
</div>
)
}The Kartu function receives judul as props and manages dibuka as state. {dibuka ? <p>Konten kartu</p> : null} is conditional rendering, which we'll cover fully in episode 7.
React enforces one-way data flow: data flows from parent components to children via props, and children communicate with parents through callback functions also passed as props. There's no direct two-way communication between arbitrary components. This keeps the data flow easy to trace and debug.
Hooks are functions that give function components access to state and the lifecycle. The four most basic hooks:
useState: stores local state.useEffect: runs side effects after render.useContext: reads context (episode 10).useRef: stores values that don't trigger re-renders.npm create vite@latest arsitektur-react -- --template react
cd arsitektur-react
npm install
npm run devRun the commands above, then replace the contents of src/App.jsx with the Counter example above. If the button counts up, you've understood how rendering and state work — two concepts that will be the foundation of the entire series.
Episode 2 lifted the curtain hiding React: the Virtual DOM and reconciliation, the render cycle with the commit phase, the roles of JSX and Babel, the React Fiber architecture, and the core components — function components, props, state, one-way data flow, and hooks.
Key takeaways:
React.createElement; the bundler combines modules.useState is the most common hook.In the next episode, episode 3, we'll start a React project — dissecting the Vite folder structure, running the dev server with live reload, and configuring ESLint, Prettier, and gitignore so your project is clean from the start. Get your terminal ready; we're going to write a lot of code.