-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
fix renderToString fails with array type children when react-dom/server render #10221
Changes from 6 commits
790e65a
c2aeb06
6fd78e5
4b28bc1
f652ed7
322fa40
deb11af
62c042e
6b4eb0e
e53e552
eafb4bd
3df964d
6f7f142
02101d5
d661c5a
97575fd
e0bd356
1d45bae
5f8a2dd
cf005dd
7f5c0a1
60e7e3e
e4dd558
59e0843
5539f09
06d9971
b42dd08
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -484,6 +484,19 @@ class ReactDOMServerRenderer { | |
if (child === null || child === false) { | ||
return ''; | ||
} else { | ||
if (Array.isArray(child)) { | ||
var frame = { | ||
children: child, | ||
childIndex: 0, | ||
context: context, | ||
footer: '', | ||
}; | ||
if (__DEV__) { | ||
frame.debugElementStack = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to do this? (Note: I'm not very familiar with this code so I'm learning it too.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "setCurrentDebugStack" method will set debugElementStack.length = 1, This is to init the debugElementStack array. The same method handles when HostCompoment return array type children.https://github.com/facebook/react/blob/master/src/renderers/shared/server/ReactPartialRenderer.js#L769 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do warnings still work? You can add a test similar to this one but using an array. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gaearo, It's done. Please review. |
||
} | ||
this.stack.push(frame); | ||
return ''; | ||
} | ||
return this.renderDOM(child, context); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's render two different types? e.g.
[<div key="1" />, <p key="2" />]
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, good idea.