MCPcopy Index your code
hub / github.com/adobe/react-spectrum / generateId

Function generateId

packages/react-aria/src/tabs/utils.ts:21–41  ·  view source on GitHub ↗
(
  state: TabListState<T> | null,
  key: Key | null | undefined,
  role: string
)

Source from the content-addressed store, hash-verified

19>();
20
21export function generateId<T>(
22 state: TabListState<T> | null,
23 key: Key | null | undefined,
24 role: string
25): string {
26 if (!state) {
27 // this case should only happen in the first render before the tabs are registered
28 return '';
29 }
30 if (typeof key === 'string') {
31 key = key.replace(/\s+/g, '');
32 }
33
34 let baseId = tabsIds.get(state);
35 if (process.env.NODE_ENV !== 'production' && !baseId) {
36 console.error(
37 'There is no tab id, please check if you have rendered the tab panel before the tab list.'
38 );
39 }
40 return `${baseId}-${role}-${key}`;
41}

Callers 2

useTabFunction · 0.90
useTabPanelFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected