1
0
Fork 0
Browse Source

vault backup: 2022-06-28 16:44:23

master
YuJian 2 years ago
parent
commit
a592911a8d
  1. 33
      React 的深入探索/React 的流程解析 - Fiber 递归/React 的深入探索 - beginWork.md

33
React 的深入探索/React 的流程解析 - Fiber 递归/React 的深入探索 - beginWork.md

@ -163,6 +163,39 @@ switch 中的 case 逻辑太多了,全部都写出来会让笔记显得特别 @@ -163,6 +163,39 @@ switch 中的 case 逻辑太多了,全部都写出来会让笔记显得特别
首先会执行 pushHostRootContext 函数,这个函数与 context 有关
**pushHostRootContext**
```javascript
function pushHostRootContext(workInProgress) {
var root = workInProgress.stateNode;
if (root.pendingContext) {
pushTopLevelContextObject(
workInProgress,
root.pendingContext,
root.pendingContext !== root.context
);
} else if (root.context) {
// Should always be set
pushTopLevelContextObject(workInProgress, root.context, false);
}
pushHostContainer(workInProgress, root.containerInfo);
}
```
```javascript
function pushTopLevelContextObject(fiber, context, didChange) {
{
if (contextStackCursor.current !== emptyContextObject) {
throw new Error("...");
}
push(contextStackCursor, context, fiber);
push(didPerformWorkStackCursor, didChange, fiber);
}
}
```
```javascript
function updateHostRoot(current, workInProgress, renderLanes) {
pushHostRootContext(workInProgress);

Loading…
Cancel
Save