@mantine/hooks
Version:
A collection of 50+ hooks for state and UI management
1 lines • 846 B
Source Map (JSON)
{"version":3,"file":"use-id.cjs","names":["randomId"],"sources":["../../src/use-id/use-id.ts"],"sourcesContent":["import { useId as useReactId, useState } from 'react';\nimport { useIsomorphicEffect } from '../use-isomorphic-effect/use-isomorphic-effect';\nimport { randomId } from '../utils';\n\nexport function useId(staticId?: string) {\n const reactId = useReactId();\n const [uuid, setUuid] = useState(`mantine-${reactId.replace(/:/g, '')}`);\n\n useIsomorphicEffect(() => {\n setUuid(randomId());\n }, []);\n\n if (typeof staticId === 'string') {\n return staticId;\n }\n\n return uuid;\n}\n"],"mappings":";;;;;AAIA,SAAgB,MAAM,UAAmB;CAEvC,MAAM,CAAC,MAAM,YAAA,GAAA,MAAA,UAAoB,YAAA,GAAA,MAAA,QADL,CACwB,QAAQ,MAAM,GAAG,GAAG;AAExE,+BAAA,0BAA0B;AACxB,UAAQA,kBAAAA,UAAU,CAAC;IAClB,EAAE,CAAC;AAEN,KAAI,OAAO,aAAa,SACtB,QAAO;AAGT,QAAO"}