Mini React
Build a small React from scratch: elements, reconciliation with keys, function components, useState, batching and useEffect.
What you will build
You will write a small React-like library in plain JavaScript, one idea per step. createElement builds element objects. render turns them into DOM nodes and later changes only what differs, and keys keep moved items attached to their nodes. Function components get state with useState, updates are batched in a , and useEffect runs side effects after the DOM is updated. In the last step a todo app written in JSX runs on your own library.
Every step ends with a note on how React 19 does the same job (fibers, lanes, the commit phase, event delegation), checked against React's source code and react.dev.
What you will learn
- Explain what JSX compiles to and what a React element is
- Reconcile old and new elements by type and key and change only what differs in the DOM
- Implement hooks that keep state on a component instance in call order
- Batch state updates in a microtask and run effects and cleanups in the right order
- Connect each part of your library to the real mechanism in React 19
Steps
- 01createElementDescribe the UI with plain objects: build elements and normalize their children.
- 02Render to the DOMTurn an element tree into real DOM nodes with props, styles and event listeners.
- 03ReconciliationRender again without rebuilding: keep nodes of the same type and change only the props that differ.
- 04KeysMatch children by key, so moved items keep their DOM nodes and state.
- 05Function componentsCall function types with their props and render what they return: zero, one or many nodes.
- 06useStateKeep state on the component instance and find it again through the order of hook calls.
- 07BatchingCollect state updates and render each component once, in a microtask.
- 08useEffectRun side effects after the DOM is updated, compare deps with Object.is and clean up.
- 09Run it: a todo appRun a todo app written in JSX on your own library and finish its filter.
Practise this
Other hands-on work on the same topics.
Incident Simulator
System Design
Weekly Challenges
Frontend History
See it in real code
Guided tours through the source of real libraries that rely on it.