UNPKG

botframework-webchat-component

Version:
13 lines (8 loc) 321 B
/* eslint no-magic-numbers: ["error", { "ignore": [2, 5, 36] }] */ import { useMemo } from 'react'; import random from 'math-random'; export default function useUniqueId(prefix) { const id = useMemo(() => random().toString(36).substr(2, 5), []); prefix = prefix ? `${prefix}--` : ''; return `${prefix}${id}`; }