Skip to content

Commit de982c6

Browse files
committed
feat(reconciler): 新增 更新阶段 源码注释
1 parent d9b41c9 commit de982c6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/react/v17.0.2/react-reconciler/src/ReactUpdateQueue.old.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,15 @@ if (__DEV__) {
166166
// 初始化更新对象
167167
export function initializeUpdateQueue<State>(fiber: Fiber): void {
168168

169+
// 对于HostRoot或者ClassComponent会使用initializeUpdateQueue创建updateQueue,然后将updateQueue挂载到fiber节点上
169170
// 创建一个更新,并将其挂载到 fiber 节点的 updateQueue 身上
170171
const queue: UpdateQueue<State> = {
171-
// 初始值
172+
// 初始值 //初始state,后面会基于这个state,根据Update计算新的state
172173
baseState: fiber.memoizedState,
173-
firstBaseUpdate: null,
174-
lastBaseUpdate: null,
174+
firstBaseUpdate: null, // Update形成的链表的头
175+
lastBaseUpdate: null, // Update形成的链表的尾
176+
//新产生的update会以单向环状链表保存在shared.pending上,计算state的时候会剪开这个环状链表,
177+
// 并且连接在 //lastBaseUpdate后
175178
shared: {
176179
pending: null,
177180
interleaved: null,

0 commit comments

Comments
 (0)