A minimal React implemented from scratch to understand how it works under the hood — createElement & virtual DOM, the fiber architecture with an interruptible work loop, reconciliation (diff + commit), function components, and hooks (useState / useEffect).
Part of my
mini-*source-code learning series. Talk is cheap — read the code.
core/ # earliest version: createElement + recursive render
vite-runner/ # full version, runnable with Vite + HMR
└── core/React.js # fiber work loop, reconciliation, hooks
The complete implementation lives in vite-runner/core/React.js.
| Topic | Implementation |
|---|---|
createElement & virtual DOM |
createElement, createTextNode |
| Fiber & interruptible work loop | workLoop + requestIdleCallback, performUnitOfWork |
| Reconciliation | reconcileChildren (effectTag: placement / update / deletion) |
| Commit phase | commitRoot, commitWork, commitDeletion |
| Function components | updateFunctionComponent |
| Hooks | useState (batched setState), useEffect (with cleanup) |
cd vite-runner
pnpm install
pnpm devFor the bare-bones version, open the root index.html directly — no build step.
手写主流框架 / 工具的最小可运行实现,每个仓库只追「核心主线」,不堆功能。
Talk is cheap. Read the code.
