1
1
import PropTypes from 'prop-types' ;
2
2
import React , { cloneElement , Component } from 'react' ;
3
3
import cx from 'classnames' ;
4
- import uuid , { reset } from '../helpers/uuid' ;
4
+ import uuid from '../helpers/uuid' ;
5
5
import childrenPropType from '../helpers/childrenPropType' ;
6
6
import Tab from './Tab' ;
7
+ import TabList from './TabList' ;
8
+ import TabPanel from './TabPanel' ;
7
9
8
10
// Determine if a node from event.target is a Tab element
9
11
function isTabNode ( node ) {
@@ -43,10 +45,6 @@ export default class Tabs extends Component {
43
45
this . state = Tabs . copyPropsToState ( this . props , this . state ) ;
44
46
}
45
47
46
- static resetIDCounter ( ) {
47
- reset ( ) ;
48
- }
49
-
50
48
getChildContext ( ) {
51
49
return {
52
50
forceRenderTabPanel : this . props . forceRenderTabPanel ,
@@ -148,7 +146,6 @@ export default class Tabs extends Component {
148
146
149
147
getChildren ( ) {
150
148
let index = 0 ;
151
- let count = 0 ;
152
149
const children = this . props . children ;
153
150
const state = this . state ;
154
151
this . tabIds = this . tabIds || [ ] ;
@@ -171,10 +168,10 @@ export default class Tabs extends Component {
171
168
return null ;
172
169
}
173
170
174
- let result = null ;
171
+ let result = child ;
175
172
176
173
// Clone TabList and Tab components to have refs
177
- if ( count ++ === 0 ) {
174
+ if ( child . type === TabList ) {
178
175
// TODO try setting the uuid in the "constructor" for `Tab`/`TabPanel`
179
176
result = cloneElement ( child , {
180
177
children : React . Children . map ( child . props . children , ( tab ) => {
@@ -211,7 +208,7 @@ export default class Tabs extends Component {
211
208
212
209
// Reset index for panels
213
210
index = 0 ;
214
- } else {
211
+ } else if ( child . type === TabPanel ) {
215
212
const id = this . panelIds [ index ] ;
216
213
const tabId = this . tabIds [ index ] ;
217
214
const selected = state . selectedIndex === index ;
0 commit comments