mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
11 lines
258 B
TypeScript
11 lines
258 B
TypeScript
|
import { useMemo } from 'react';
|
||
|
|
||
|
// Generate a globally unique ID that is stable across renders.
|
||
|
export const useId = (prefix = 'useId'): string => {
|
||
|
return useMemo(() => {
|
||
|
return `${prefix}-${counter++}`;
|
||
|
}, [prefix]);
|
||
|
};
|
||
|
|
||
|
let counter = 0;
|