File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ export namespace TabsProps {
4747 } [ ] ;
4848 selectedTabId : string ;
4949 onTabChange : ( tabId : string ) => void ;
50- children ?: NonNullable < ReactNode > ;
50+ children : ReactNode ;
5151 } ;
5252}
5353
@@ -68,8 +68,6 @@ export const Tabs = memo(
6868
6969 assert < Equals < keyof typeof rest , never > > ( ) ;
7070
71- const id = useId ( ) ;
72-
7371 const getSelectedTabIndex = ( ) =>
7472 tabs . findIndex ( tab =>
7573 "content" in tab ? tab . isDefault ?? false : tab . tabId === selectedTabId
@@ -96,8 +94,17 @@ export const Tabs = memo(
9694 }
9795 } ) ;
9896
99- const getPanelId = ( tabIndex : number ) => `tabpanel-${ id } -${ tabIndex } -panel` ;
100- const getTabId = ( tabIndex : number ) => `tabpanel-${ id } -${ tabIndex } ` ;
97+ const { getPanelId, getTabId } = ( function useClosure ( ) {
98+ const id = useId ( ) ;
99+
100+ const getPanelId = ( tabIndex : number ) => `tabpanel-${ id } -${ tabIndex } -panel` ;
101+ const getTabId = ( tabIndex : number ) => `tabpanel-${ id } -${ tabIndex } ` ;
102+
103+ return {
104+ getPanelId,
105+ getTabId
106+ } ;
107+ } ) ( ) ;
101108
102109 return (
103110 < div className = { cx ( fr . cx ( "fr-tabs" ) , className ) } ref = { ref } style = { style } { ...rest } >
You can’t perform that action at this time.
0 commit comments