From 41c0d2ebae27b9c64de05d3e200a24b4d5351479 Mon Sep 17 00:00:00 2001 From: YuJian Date: Tue, 28 Jun 2022 16:34:23 +0800 Subject: [PATCH] vault backup: 2022-06-28 16:34:23 --- .../React 的深入探索 - beginWork.md | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) 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 + ); + } + } + + ...... } ```