This repository has been archived by the owner on Aug 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from FormidableLabs/bug-onlyChildIsString
Bug: Make Children.only check handle string children
- Loading branch information
Showing
4 changed files
with
18 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,16 +111,20 @@ var resolveStyles = function (component, renderedElement, existingKeyMap) { | |
var newChildren = null; | ||
var oldChildren = renderedElement.props.children; | ||
if (oldChildren) { | ||
if (React.Children.count(oldChildren) === 1) { | ||
var child = React.Children.only(oldChildren); | ||
newChildren = resolveStyles(component, child, existingKeyMap); | ||
// If a React Element is an only child, don't wrap it in an array for | ||
// React.Children.map() for React.Children.only() compatibility. | ||
if (React.Children.count(oldChildren) === 1 && oldChildren.type) { | ||
var onlyChild = React.Children.only(oldChildren); | ||
This comment has been minimized.
Sorry, something went wrong.
ianobermiller
Contributor
|
||
|
||
This comment has been minimized.
Sorry, something went wrong. |
||
newChildren = resolveStyles(component, onlyChild, existingKeyMap); | ||
} else { | ||
newChildren = React.Children.map( | ||
oldChildren, | ||
function (child) { | ||
if (React.isValidElement(child)) { | ||
return resolveStyles(component, child, existingKeyMap); | ||
} | ||
|
||
return child; | ||
} | ||
); | ||
|
remove
.only