Fix button render with null or undefined child. (#5473)

* Fix button render with null or undefined child.

Fix bug #5472

* Add missing semicolon

* Make if statement braced.

......
This commit is contained in:
Sebastian Blade 2017-03-24 13:10:27 +08:00 committed by 偏右
parent d6d62f6754
commit 83f85a371a

View File

@ -12,6 +12,10 @@ function isString(str) {
// Insert one space between two chinese characters automatically.
function insertSpace(child) {
// Check the child if is undefined or null.
if (child == null) {
return;
}
if (isString(child.type) && isTwoCNChar(child.props.children)) {
return React.cloneElement(child, {},
child.props.children.split('').join(' '));