1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-11-01 19:07:38 +01:00
unleash.unleash/frontend/src/hooks/useId.ts

11 lines
258 B
TypeScript
Raw Normal View History

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;