favycon/utils/ids.ts
Rui Saraiva a611bcd4fe
feat: add dark mode toggle component (#21)
* feat: add dark mode toggle component

Add dark mode toggle component with custom hook

fix #14

* feat(dark-mode): add svgs, fix flash and css modules support

* docs: update get start guide and fix typos
2020-04-11 23:13:21 +01:00

15 lines
265 B
TypeScript

const idCounter: { [key: string]: number } = {}
export const uniqueId = (prefix = '$unique$') => {
if (!idCounter[prefix]) {
idCounter[prefix] = 0
}
const id = ++idCounter[prefix]
if (prefix === '$unique$') {
return `${id}`
}
return `${prefix}${id}`
}