1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02: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;