From 9dea14ab35fa80af43ac5531a1fa31eb0a461291 Mon Sep 17 00:00:00 2001 From: YuJian Date: Tue, 28 Jun 2022 10:08:53 +0800 Subject: [PATCH] vault backup: 2022-06-28 10:08:53 --- .../React 的深入探索 - beginWork.md | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/React 的深入探索/React 的流程解析 - Fiber 递归/React 的深入探索 - beginWork.md b/React 的深入探索/React 的流程解析 - Fiber 递归/React 的深入探索 - beginWork.md index dd62f4d..a6b18aa 100644 --- a/React 的深入探索/React 的流程解析 - Fiber 递归/React 的深入探索 - beginWork.md +++ b/React 的深入探索/React 的流程解析 - Fiber 递归/React 的深入探索 - beginWork.md @@ -38,7 +38,26 @@ if (current !== null) { ### current 不为空 -在 current 不为空的逻辑中,会先 +在 current 不为空的逻辑中,会先取出先前存储在 Fiber 节点中的新旧 props,连同其他几个判断条件一起做 if 判断,判断条件如下: +1. 判断 p + +```javascript +var oldProps = current.memoizedProps; +var newProps = workInProgress.pendingProps; + +if ( + // 对比新旧 props + oldProps !== newProps || + // 检查 context 是否发生变化 + hasContextChanged() || + // 判断 Fiber type 是否发生变化 + (workInProgress.type !== current.type ) +) { + didReceiveUpdate = true; +} else { + ...... +} +``` ### current 为空