Skip to content

Commit

Permalink
fix: the children of <Collapse /> could be null
Browse files Browse the repository at this point in the history
  • Loading branch information
ystarlongzi committed Nov 17, 2016
1 parent 312f1fb commit d6f846a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Collapse.jsx
Expand Up @@ -91,7 +91,10 @@ const Collapse = React.createClass({
getItems() {
const activeKey = this.state.activeKey;
const { prefixCls, accordion } = this.props;
return Children.map(this.props.children, (child, index) => {
const newChildren = [];

Children.forEach(this.props.children, (child, index) => {
if (!child) return;
// If there is no key provide, use the panel order as default key
const key = child.key || String(index);
const header = child.props.header;
Expand All @@ -112,8 +115,10 @@ const Collapse = React.createClass({
onItemClick: this.onClickItem(key).bind(this),
};

return React.cloneElement(child, props);
newChildren.push(React.cloneElement(child, props));
});

return newChildren;
},

setActiveKey(activeKey) {
Expand Down

0 comments on commit d6f846a

Please sign in to comment.