Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update multi.md #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions docs/diff/multi.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
```jsx
function List () {
return (
<ul>
<li key="0">0</li>
<li key="1">1</li>
<li key="2">2</li>
<li key="3">3</li>
</ul>
<>
<p key="0">0</p>
<p key="1">1</p>
<p key="2">2</p>
<p key="3">3</p>
</>
)
}
```
Expand All @@ -21,18 +21,18 @@ 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,
type: "ul"
}
```

这种情况下,`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)看到这段源码逻辑

Expand Down