diff --git a/packages/eds-utils/src/hooks/useId.ts b/packages/eds-utils/src/hooks/useId.ts index 4b942781e7..19203a55be 100644 --- a/packages/eds-utils/src/hooks/useId.ts +++ b/packages/eds-utils/src/hooks/useId.ts @@ -1,14 +1,14 @@ import { useEffect, useState } from 'react' +let counter = 0 + export const useId = (idOverride: string, type?: string): string => { const [defaultId, setDefaultId] = useState(idOverride) const id = idOverride || defaultId useEffect(() => { if (defaultId == null) { - setDefaultId( - `eds-${type ? type + `-` : ''}${Math.round(Math.random() * 1e5)}`, - ) + setDefaultId(`eds-${type ? type + `-` : ''}${counter++}`) } }, [defaultId, type]) return id