• Stars
    star
    208
  • Rank 189,015 (Top 4 %)
  • Language
    JavaScript
  • Created almost 7 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Build react from scratch (code + blog)

Learn React Source Code

Read it Online

What You'll Learn

  • React 是怎样将 JSX mount 成为真正的 DOM 节点的
  • React 是怎样用 Virtual DOM 的 Diff 算法更新 Element tree,然后映射到真正的 DOM 变化的
  • 什么是 Virtual DOM,它的优势是什么,以及它和 React 是怎样结合使用的
  • 对 React 的核心功能有一个更深入的理解

What This Doesn't Cover

由于这是一个 React 的最小实现,它并没有实现 React 的全部功能,以下这些功能是这个代码库没有涵盖到的。(这个 list 在 Paul 2016 的演讲中被提及到)

  • defaultProps
  • propTypes
  • keys
  • refs
  • batching
  • events
  • createClass
  • warnings
  • browser
  • optimizations
  • rendering null
  • DOM updates
  • SVG
  • life cycle hooks
  • error boundaries
  • perf tooling and optimizing
  • PureComponents
  • functional components

但是当你读完整个博客和代码后,相信你已经会有对实现这其中的几个功能的一些初步思考。

Run the Demo

> cd ./demo
> npm install
> npm run watch

Open the index.html manually.

Disclaimers

  1. Most code of Dilithium you've seen in this repo is originally written by @zpao, at building-react-from-scratch, but it's also slightly changed here. I'll keep digging some of the listed features and adding blog and source code on top of the current codebase.

  2. The diffing algorithm used in the Dilithium is the stack reconcilliation, not the new fiber architecture.

  3. The code snippets in the blogs are sometimes somewhat different from that in the codebase. This is for better readablity and a more smooth learning curve.

Liscense

MIT@Chang

More Repositories

1

v-dom

👉 A minimal implementation of the Virtual DOM
JavaScript
149
star
2

css-filter

Upload an image and add filters to it. Pure CSS, no black magic.
JavaScript
99
star
3

image-screenshot

download an image node along with its css properties
JavaScript
54
star
4

zion

[Deprecated] A tentative, light-weight 2D game framework based on HTML5 canvas.
JavaScript
44
star
5

Migration-to-Suspense

Slides and demo of D2 Forum in Jan. 2019
36
star
6

tetris-redux

🏆 A React / Redux implementation of the Tetris game.
JavaScript
29
star
7

canvas-image-cache

A promise-based utility to cache images in canvas to enhance rendering efficiency and prevent flickering
JavaScript
14
star
8

react-suspense-demo

Use React Suspense today
JavaScript
11
star
9

react-animation-wrapper

🔮 Components animation wrapper done right
JavaScript
11
star
10

leetcode

💫 Python / JavaScript solutions for LeetCode
Python
9
star
11

zakas

🤖 A desktop Siri-like voice manager bot, to automate your daily routine.
Python
7
star
12

til

✨ Curated list of useful code snippets / programming tips & knowledge. Check my Gists as well!
Shell
6
star
13

memoize

A JavaScript function wrapper to memorize / cache result with the same input
JavaScript
6
star
14

tetris-mobx

A React / MobX implementation of the Tetris game.
JavaScript
6
star
15

React-Kanban-Board

📋 A checklist SPA implemented with React
JavaScript
5
star
16

easy-stackoverflow

🙊A Chrome extension for StackOverflow
JavaScript
5
star
17

pubsub

🔮 The JavaScript implementation of the publish/subscribe pattern.
JavaScript
5
star
18

react-provider-standalone

The standalone React components <Provider /> wrapper.
JavaScript
5
star
19

node-online-snake

The html5 snake game implemented with Express.js and Socket.io
JavaScript
5
star
20

dumb-state

A simple state management tool that supports undo, redo, etc.
JavaScript
4
star
21

handwriting

📖 A web application to practice your handwriting.
JavaScript
4
star
22

focus-helper

A chrome extension to help you boost your focus in a period of time
4
star
23

hands-on-react-hooks

A handful of custom React hooks, mostly for education purpose.
3
star
24

sane-plural

get the plural form in a sane way
JavaScript
3
star
25

try-infinitely

a simple helper function to make an error-prone call infinitely / or until some value is truthy
JavaScript
3
star
26

tiny-react-ui

A lightweight, easy-to-use ui component kit for React
3
star
27

Backbone-Todo-List

The todo list based on Backbone.js
HTML
3
star
28

greedy-snake

A simple html5 game aimed at children aged above 3. LOL
HTML
3
star
29

keybus

🏄 Support simultaneous multi-keypress handler. Especially useful in game development on web browser.
JavaScript
3
star
30

Front-End-Data-Visualization

👀 Web Data Visualization for the graduate thesis in 2017.
JavaScript
3
star
31

hook-useEffect-repro

[This is a wrong usage example]
JavaScript
2
star
32

react-undo-redo

An Higher Order Component that gives you ability to undo / redo state changes.
2
star
33

mini-observer

👀 A redux-like implementation of the observer pattern in JavaScript
JavaScript
2
star
34

express-socket.io-boilerplate

An un-opinionated, minimal boilerplate to get started with Express.JS and Socket.io
HTML
2
star
35

weather-cli

☁️ A Node.js Command Line Tool to Know the Weather Data
1
star
36

AsyncImage

Lazy load image with React suspense
1
star
37

sponsibly

http://cyan33.github.io/sponsibly
HTML
1
star
38

react-collapsed-image

JavaScript
1
star
39

Data-Structure-and-Algorithms-in-JavaScript

A Minimal Implementation of the Common-Seen Data Structure and Algorithms in JavaScript.
JavaScript
1
star
40

fast-scroll-top

A Chrome extension to save your pain of scrolling back to the top of the page.
JavaScript
1
star
41

codec

📠 A light weight codec implemented in JavaScript, aimed for both browser and node.js
JavaScript
1
star
42

is-equal

a JavaScript function utility to check if two things are content-wise equal or not
JavaScript
1
star
43

naming-transformer

Switching between variable naming conventions like camel, snake, and general title
JavaScript
1
star