11import PropTypes from 'prop-types' ;
2- import React , { cloneElement , useRef } from 'react' ;
2+ import React , { cloneElement , useRef , useId } from 'react' ;
33import cx from 'clsx' ;
4- import uuid from '../helpers/uuid' ;
54import { childrenPropType } from '../helpers/propTypes' ;
65import { getTabsCount as getTabsCountHelper } from '../helpers/count' ;
76import { deepMap } from '../helpers/childrenDeepMap' ;
@@ -71,7 +70,6 @@ const propTypes = {
7170const UncontrolledTabs = ( props ) => {
7271 let tabNodes = useRef ( [ ] ) ;
7372 let tabIds = useRef ( [ ] ) ;
74- let panelIds = useRef ( [ ] ) ;
7573 const ref = useRef ( ) ;
7674
7775 function setSelected ( index , event ) {
@@ -180,15 +178,14 @@ const UncontrolledTabs = (props) => {
180178 } = props ;
181179
182180 tabIds . current = tabIds . current || [ ] ;
183- panelIds . current = panelIds . current || [ ] ;
184181 let diff = tabIds . current . length - getTabsCount ( ) ;
185182
186183 // Add ids if new tabs have been added
187184 // Don't bother removing ids, just keep them in case they are added again
188185 // This is more efficient, and keeps the uuid counter under control
186+ const id = useId ( ) ;
189187 while ( diff ++ < 0 ) {
190- tabIds . current . push ( uuid ( ) ) ;
191- panelIds . current . push ( uuid ( ) ) ;
188+ tabIds . current . push ( `${ id } ${ tabIds . current . length } ` ) ;
192189 }
193190
194191 // Map children to dynamically setup refs
@@ -225,7 +222,6 @@ const UncontrolledTabs = (props) => {
225222 tabNodes . current [ key ] = node ;
226223 } ,
227224 id : tabIds . current [ listIndex ] ,
228- panelId : panelIds . current [ listIndex ] ,
229225 selected,
230226 focus : selected && ( focus || wasTabFocused ) ,
231227 } ;
@@ -242,8 +238,7 @@ const UncontrolledTabs = (props) => {
242238 } ) ;
243239 } else if ( isTabPanel ( child ) ) {
244240 const props = {
245- id : panelIds . current [ index ] ,
246- tabId : tabIds . current [ index ] ,
241+ id : tabIds . current [ index ] ,
247242 selected : selectedIndex === index ,
248243 } ;
249244
0 commit comments