Fix editable Tabs key error

close #2721 & #2725
This commit is contained in:
afc163 2016-08-17 15:17:10 +08:00
parent 6a86811e95
commit 471743f4c7

View File

@ -1,5 +1,5 @@
import RcTabs from 'rc-tabs'; import RcTabs from 'rc-tabs';
import React, { cloneElement, Children } from 'react'; import React, { cloneElement } from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import Icon from '../icon'; import Icon from '../icon';
@ -47,7 +47,10 @@ export default class Tabs extends React.Component {
// only card type tabs can be added and closed // only card type tabs can be added and closed
if (type === 'editable-card') { if (type === 'editable-card') {
children = Array.isArray(children) ? children : [children]; children = Array.isArray(children) ? children : [children];
children = Children.map(children, (child, index) => { children = children.map((child, index) => {
if (Array.isArray(child)) {
return child;
}
return cloneElement(child, { return cloneElement(child, {
tab: <div> tab: <div>
{child.props.tab} {child.props.tab}