1
1
import PropTypes from 'prop-types' ;
2
- import React , { cloneElement , useRef } from 'react' ;
2
+ import React , { cloneElement , useRef , useId } from 'react' ;
3
3
import cx from 'clsx' ;
4
- import uuid from '../helpers/uuid' ;
5
4
import { childrenPropType } from '../helpers/propTypes' ;
6
5
import { getTabsCount as getTabsCountHelper } from '../helpers/count' ;
7
6
import { deepMap } from '../helpers/childrenDeepMap' ;
@@ -71,7 +70,6 @@ const propTypes = {
71
70
const UncontrolledTabs = ( props ) => {
72
71
let tabNodes = useRef ( [ ] ) ;
73
72
let tabIds = useRef ( [ ] ) ;
74
- let panelIds = useRef ( [ ] ) ;
75
73
const ref = useRef ( ) ;
76
74
77
75
function setSelected ( index , event ) {
@@ -180,15 +178,14 @@ const UncontrolledTabs = (props) => {
180
178
} = props ;
181
179
182
180
tabIds . current = tabIds . current || [ ] ;
183
- panelIds . current = panelIds . current || [ ] ;
184
181
let diff = tabIds . current . length - getTabsCount ( ) ;
185
182
186
183
// Add ids if new tabs have been added
187
184
// Don't bother removing ids, just keep them in case they are added again
188
185
// This is more efficient, and keeps the uuid counter under control
186
+ const id = useId ( ) ;
189
187
while ( diff ++ < 0 ) {
190
- tabIds . current . push ( uuid ( ) ) ;
191
- panelIds . current . push ( uuid ( ) ) ;
188
+ tabIds . current . push ( `${ id } ${ tabIds . current . length } ` ) ;
192
189
}
193
190
194
191
// Map children to dynamically setup refs
@@ -225,7 +222,6 @@ const UncontrolledTabs = (props) => {
225
222
tabNodes . current [ key ] = node ;
226
223
} ,
227
224
id : tabIds . current [ listIndex ] ,
228
- panelId : panelIds . current [ listIndex ] ,
229
225
selected,
230
226
focus : selected && ( focus || wasTabFocused ) ,
231
227
} ;
@@ -242,8 +238,7 @@ const UncontrolledTabs = (props) => {
242
238
} ) ;
243
239
} else if ( isTabPanel ( child ) ) {
244
240
const props = {
245
- id : panelIds . current [ index ] ,
246
- tabId : tabIds . current [ index ] ,
241
+ id : tabIds . current [ index ] ,
247
242
selected : selectedIndex === index ,
248
243
} ;
249
244
0 commit comments