@mantine/hooks
Version:
A collection of 50+ hooks for state and UI management
1 lines • 856 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,OAAiB,EAAE,QAAQ,MAAM,EAAE,GAAG;CAEvE,8BAAA,0BAA0B;EACxB,QAAQA,kBAAAA,SAAS,CAAC;CACpB,GAAG,CAAC,CAAC;CAEL,IAAI,OAAO,aAAa,UACtB,OAAO;CAGT,OAAO;AACT"}