Skip to content

Commit a4d30d2

Browse files
author
guimeisang
committed
add: 看源码是真的很枯燥
1 parent 0d5b79d commit a4d30d2

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
理念:
2+
3+
第一:
4+
15
1. 使用reconciler(协调器)实现了一个reactDOM
26
感觉很多都不太理解吧
37

@@ -11,3 +15,19 @@ React 内部实现的一套状态更新机制,支持任务不同的优先级
1115
其中每个任务更新单元为react element 对应的Fiber节点
1216

1317
2.2 Fiber架构的实现原理
18+
主要是讲解了下FiberNode的结构
19+
20+
2.3 Fiber架构的工作原理
21+
- 双缓存,和GPU原理差不多
22+
即:curren Fiber Tree 和 workInProgress Fiber Tree
23+
并且关于两个棵之前替换,非常精彩
24+
25+
第二:前置知识
26+
- 源码的文件结构
27+
- 调试源码
28+
- 深入理解JSX
29+
30+
架构篇
31+
32+
33+

src/Core/FiberNode.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ function FiberNode(
55
mode: TypeOfMode
66
) {
77
// 做为静态数据结构的属性
8-
this.tag = tag
9-
this.key = key
10-
this.elementType = null
11-
this.type = null
12-
this.stateNode = null
8+
this.tag = tag // Fiber对应的组件类型 Function、Class、Host
9+
this.key = key // key 属性
10+
this.elementType = null // 大部分情况同type,某些情况不同,比如FunctionComponent使用React.memo包裹
11+
this.type = null // 对于 FunctionComponent,指函数本身,对于ClassComponent,指class,对于HostComponent,指DOM节点tagName
12+
this.stateNode = null // Fiber对应真实的DOM节点
1313

1414
// 用于连接其他Fiber节点形成Fiber树
1515
this.return = null
@@ -19,7 +19,7 @@ function FiberNode(
1919

2020
this.ref = null
2121

22-
// 做为动态的工作单元的属性
22+
// 做为动态的工作单元的属性,保存本次更新造成的状态改变相关信息
2323
this.pendingProps = pendingProps
2424
this.memoizedProps = null
2525
this.updateQueue = null

0 commit comments

Comments
 (0)