|
|
@ -161,8 +161,29 @@ do { |
|
|
|
|
|
|
|
|
|
|
|
关于 commitLayoutEffects: [[React 的深入探索 - commitLayoutEffects]] |
|
|
|
关于 commitLayoutEffects: [[React 的深入探索 - commitLayoutEffects]] |
|
|
|
|
|
|
|
|
|
|
|
结束三个循环之后 commit 阶段并没有结束,还会进入接下来逻辑 |
|
|
|
结束三个循环之后 commit 阶段并没有结束,还会进入接下来的逻辑 |
|
|
|
|
|
|
|
|
|
|
|
```javascript |
|
|
|
```javascript |
|
|
|
|
|
|
|
var rootDidHavePassiveEffects = rootDoesHavePassiveEffects; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rootDoesHavePassiveEffects) { |
|
|
|
|
|
|
|
// 本次更新存在 useEffect |
|
|
|
|
|
|
|
rootDoesHavePassiveEffects = false; |
|
|
|
|
|
|
|
// 将 root 赋值给 rootWithPendingPassiveEffects,没错就是开头的循环 |
|
|
|
|
|
|
|
rootWithPendingPassiveEffects = root; |
|
|
|
|
|
|
|
pendingPassiveEffectsLanes = lanes; |
|
|
|
|
|
|
|
pendingPassiveEffectsRenderPriority = renderPriorityLevel; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// 本次更新不存在 useEffect |
|
|
|
|
|
|
|
nextEffect = firstEffect; |
|
|
|
|
|
|
|
while (nextEffect !== null) { |
|
|
|
|
|
|
|
var nextNextEffect = nextEffect.nextEffect; |
|
|
|
|
|
|
|
// 循环设置为 null,目的是为了垃圾回收 |
|
|
|
|
|
|
|
nextEffect.nextEffect = null; |
|
|
|
|
|
|
|
if (nextEffect.effectTag & Deletion) { |
|
|
|
|
|
|
|
detachFiberAfterEffects(nextEffect); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
nextEffect = nextNextEffect; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
``` |
|
|
|
``` |