1
0
Fork 0
Browse Source

vault backup: 2022-04-26 17:12:42

master
YuJian 3 years ago
parent
commit
4b67db996b
  1. 25
      React 的源码深入/React 的流程解析 - commit 阶段/React 的流程解析 - commit阶段.md

25
React 的源码深入/React 的流程解析 - commit 阶段/React 的流程解析 - commit阶段.md

@ -161,8 +161,29 @@ do { @@ -161,8 +161,29 @@ do {
关于 commitLayoutEffects: [[React 的深入探索 - commitLayoutEffects]]
结束三个循环之后 commit 阶段并没有结束,还会进入接下来逻辑
结束三个循环之后 commit 阶段并没有结束,还会进入接下来逻辑
```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;
}
}
```
Loading…
Cancel
Save