Skip to content

Commit b39dbde

Browse files
fix: restore getDefaultOUIAId for deprecated class components
The deprecated Table class component in react-table still requires getDefaultOUIAId which cannot be replaced with hooks. Re-added as a simplified legacy function marked @deprecated. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 1ff98e0 commit b39dbde

File tree

1 file changed

+12
-0
lines changed
  • packages/react-core/src/helpers/OUIA

1 file changed

+12
-0
lines changed

packages/react-core/src/helpers/OUIA/ouia.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,15 @@ export const useOUIAId = (componentType: string, id?: OuiaId, variant?: string)
5555
const generatedId = useSSRSafeId(`${ouiaPrefix}${componentType}-${variant ? `${variant}-` : ''}`);
5656
return id ?? generatedId;
5757
};
58+
59+
let uid = 0;
60+
61+
/**
62+
* Legacy counter-based OUIA ID generator for class components that cannot use hooks.
63+
* Prefer useOUIAId or useOUIAProps for functional components.
64+
*
65+
* @deprecated Use useOUIAId in functional components instead.
66+
*/
67+
export function getDefaultOUIAId(componentType: string, variant?: string) {
68+
return `${ouiaPrefix}${componentType}-${variant ? `${variant}-` : ''}${++uid}`;
69+
}

0 commit comments

Comments
 (0)