diff --git a/React 的深入探索/React 的流程解析 - Fiber 递归/React 的深入探索 - beginWork.md b/React 的深入探索/React 的流程解析 - Fiber 递归/React 的深入探索 - beginWork.md index a346e23..ab88f57 100644 --- a/React 的深入探索/React 的流程解析 - Fiber 递归/React 的深入探索 - beginWork.md +++ b/React 的深入探索/React 的流程解析 - Fiber 递归/React 的深入探索 - beginWork.md @@ -161,6 +161,8 @@ switch 中的 case 逻辑太多了,全部都写出来会让笔记显得特别 ### updateHostRoot +首先会执行 pushHostRootContext 函数,这个函数与 context 有关 + ```javascript function updateHostRoot(current, workInProgress, renderLanes) { pushHostRootContext(workInProgress); @@ -168,9 +170,30 @@ function updateHostRoot(current, workInProgress, renderLanes) { if (current === null || updateQueue === null) { throw new Error("..."); } + var nextProps = workInProgress.pendingProps; var prevState = workInProgress.memoizedState; - var prevChildren = prevState.element; + var prevChildren = prevState.element; + cloneUpdateQueue(current, workInProgress); + processUpdateQueue(workInProgress, nextProps, null, renderLanes); + var nextState = workInProgress.memoizedState; + var root = workInProgress.stateNode; + + { + var nextCache = nextState.cache; + pushRootCachePool(root); + pushCacheProvider(workInProgress, nextCache); + + if (nextCache !== prevState.cache) { + propagateContextChange( + workInProgress, + CacheContext, + renderLanes + ); + } + } + + ...... } ```