-
Notifications
You must be signed in to change notification settings - Fork 47.4k
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
support Call and Return components in React.Children calls #11422
Changes from 3 commits
e8956cb
c75180e
e76202f
3d22e79
d20d0c2
0a5e5f0
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 |
---|---|---|
|
@@ -25,6 +25,12 @@ var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec. | |
var REACT_ELEMENT_TYPE = | ||
(typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element')) || | ||
0xeac7; | ||
const REACT_CALL_TYPE = | ||
(typeof Symbol === 'function' && Symbol.for && Symbol.for('react.call')) || | ||
0xeac8; | ||
const REACT_RETURN_TYPE = | ||
(typeof Symbol === 'function' && Symbol.for && Symbol.for('react.return')) || | ||
0xeac9; | ||
const REACT_PORTAL_TYPE = | ||
(typeof Symbol === 'function' && Symbol.for && Symbol.for('react.portal')) || | ||
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. Does it make sense to share the 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. Doesn't matter right now. This code executes once. Although it probably makes sense to copy how we do it in |
||
0xeaca; | ||
|
@@ -128,6 +134,8 @@ function traverseAllChildrenImpl( | |
// The following is inlined from ReactElement. This means we can optimize | ||
// some checks. React Fiber also inlines this logic for similar purposes. | ||
(type === 'object' && children.$$typeof === REACT_ELEMENT_TYPE) || | ||
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. Can we return this into a switch somehow? |
||
(type === 'object' && children.$$typeof === REACT_CALL_TYPE) || | ||
(type === 'object' && children.$$typeof === REACT_RETURN_TYPE) || | ||
(type === 'object' && children.$$typeof === REACT_PORTAL_TYPE) | ||
) { | ||
callback( | ||
|
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.
Minor nit: let's reorder them before the portal (the numbers go in sequential order).
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.
Makes sense.