From 87e895eebdf619a04b8bb355d604479f041d4adf Mon Sep 17 00:00:00 2001 From: Cedric GESTES Date: Wed, 20 May 2015 08:46:20 +0200 Subject: [PATCH] toolbar: fix for empty toolbar --- src/toolbar/toolbar.jsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/toolbar/toolbar.jsx b/src/toolbar/toolbar.jsx index a981644a490e01..4d5c1c7ade75bc 100644 --- a/src/toolbar/toolbar.jsx +++ b/src/toolbar/toolbar.jsx @@ -30,11 +30,12 @@ var Toolbar = React.createClass({ render: function() { - var firstChild = this.props.children[0]; - var lastChild = this.props.children[this.props.children.length - 1]; - if (firstChild.type.displayName === 'ToolbarGroup') firstChild = React.cloneElement(firstChild, {firstChild: true}); - if (lastChild.type.displayName === 'ToolbarGroup') lastChild = React.cloneElement(lastChild, {lastChild: true}); - + if (React.Children.count > 0) { + var firstChild = this.props.children[0]; + var lastChild = this.props.children[this.props.children.length - 1]; + if (firstChild.type.displayName === 'ToolbarGroup') firstChild = React.cloneElement(firstChild, {firstChild: true}); + if (lastChild.type.displayName === 'ToolbarGroup') lastChild = React.cloneElement(lastChild, {lastChild: true}); + } return (
{this.props.children}