From 6020105d9e8921e6a7b9d318064f0f1c8b69707f Mon Sep 17 00:00:00 2001 From: YuJian920 Date: Sun, 8 May 2022 17:03:09 +0800 Subject: [PATCH] vault backup: 2022-05-08 17:03:09 --- .../React 的流程解析 - Fiber 递归.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/React 的源码深入/React 的流程解析 - Fiber 递归/React 的流程解析 - Fiber 递归.md b/React 的源码深入/React 的流程解析 - Fiber 递归/React 的流程解析 - Fiber 递归.md index 8abf822..6dac705 100644 --- a/React 的源码深入/React 的流程解析 - Fiber 递归/React 的流程解析 - Fiber 递归.md +++ b/React 的源码深入/React 的流程解析 - Fiber 递归/React 的流程解析 - Fiber 递归.md @@ -10,7 +10,24 @@ Fiber 递归开始首先会交由 createWorkInProgress 函数生成 WorkInProgre ```javascript function createWorkInProgress(current, pendingProps) { - + if (workInProgress === null) { + workInProgress = createFiber( + current.tag, + pendingProps, + current.key, + current.mode + ); + // 赋值同名属性 + workInProgress.elementType = current.elementType; + workInProgress.type = current.type; + workInProgress.stateNode = current.stateNode; + + // 通过 alternate 属性互相链接 + workInProgress.alternate = current; + current.alternate = workInProgress; + } + + ...... } ```