From 629cee907d9b6aa5783e1853aee623392dc745c6 Mon Sep 17 00:00:00 2001 From: Verten <342054368@qq.com> Date: Wed, 18 May 2022 17:57:00 +0800 Subject: [PATCH] Update multi.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 按照原来文章中的FunctionComponent组件形式,走的应该还是Single Element的逻辑。 --- docs/diff/multi.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/diff/multi.md b/docs/diff/multi.md index 8ab695b..826a9f0 100644 --- a/docs/diff/multi.md +++ b/docs/diff/multi.md @@ -4,12 +4,12 @@ ```jsx function List () { return ( - + <> +

0

+

1

+

2

+

3

+ ) } ``` @@ -21,10 +21,10 @@ function List () { key: null, props: { children: [ - {$$typeof: Symbol(react.element), type: "li", key: "0", ref: null, props: {…}, …} - {$$typeof: Symbol(react.element), type: "li", key: "1", ref: null, props: {…}, …} - {$$typeof: Symbol(react.element), type: "li", key: "2", ref: null, props: {…}, …} - {$$typeof: Symbol(react.element), type: "li", key: "3", ref: null, props: {…}, …} + {$$typeof: Symbol(react.element), type: "p", key: "0", ref: null, props: {…}, …} + {$$typeof: Symbol(react.element), type: "p", key: "1", ref: null, props: {…}, …} + {$$typeof: Symbol(react.element), type: "p", key: "2", ref: null, props: {…}, …} + {$$typeof: Symbol(react.element), type: "p", key: "3", ref: null, props: {…}, …} ] }, ref: null, @@ -32,7 +32,7 @@ function List () { } ``` -这种情况下,`reconcileChildFibers`的`newChild`参数类型为`Array`,在`reconcileChildFibers`函数内部对应如下情况: +通过[这里](https://github.com/facebook/react/blob/1fb18e22ae66fdb1dc127347e169e73948778e5a/packages/react-reconciler/src/ReactChildFiber.new.js#L1294)的逻辑,`newChild`会被转化成`newChild.props.children`,所以这种情况下,`reconcileChildFibers`的`newChild`参数类型为`Array`,在`reconcileChildFibers`函数内部对应如下情况: > 你可以在[这里](https://github.com/facebook/react/blob/1fb18e22ae66fdb1dc127347e169e73948778e5a/packages/react-reconciler/src/ReactChildFiber.new.js#L1352)看到这段源码逻辑