本项目 fork 自 pomber/didact 的 8eb7ffd - Brute force reconciliation 这个较为原始的 commit,因为这个 commit 之前的实现较为基础易懂,主要实现 Rendering DOM elements 和 Element creation and JSX,所以自己就从这个 commit 开始实现 Virtual DOM and reconciliation 、Components and State 以及 Fiber: Incremental reconciliation 部分,实现思路参考了原 repo,但可能不完全一致,这个独立的 repo 也主要是记录自己的思考及实现过程。
运行 demo:
git clone https://github.com/Weiting-Zhang/didact
cd didact
yarn
yarn demo
http-server -p 8099
没有安装 http-server 可以 npm install -g http-server
之后可以打开 http://127.0.0.1:8099/examples/ 查看效果
以下是原 README
This repository goes together with a series of posts that explains how to build React from scratch step by step. You can jump straight to the last post which is self-contained and includes everything.
| Blog Post | Code sample | Commits | Other languages |
|---|---|---|---|
| Introduction | |||
| Rendering DOM elements | codepen | diff | 中文 |
| Element creation and JSX | codepen | diff | 中文 |
| Virtual DOM and reconciliation | codepen | diff diff diff | 中文 |
| Components and State | codepen | diff | 中文 |
| Fiber: Incremental reconciliation (self-contained post) | codepen | diff diff | 中文 |
| The one with Hooks (self-contained post) | codesandbox |
Follow @pomber on twitter for updates.
The MIT License (MIT)
