UNPKG

@mantine/hooks

Version:

A collection of 50+ hooks for state and UI management

20 lines (19 loc) 699 B
"use client"; import { randomId } from "../utils/random-id/random-id.mjs"; import { useIsomorphicEffect } from "../use-isomorphic-effect/use-isomorphic-effect.mjs"; import { useId, useRef, useState } from "react"; //#region packages/@mantine/hooks/src/use-id/use-id.ts function useId$1(staticId) { const [uuid, setUuid] = useState(`mantine-${useId().replace(/:/g, "")}`); const hasInitializedRef = useRef(false); useIsomorphicEffect(() => { if (hasInitializedRef.current) return; hasInitializedRef.current = true; setUuid(randomId()); }, []); if (typeof staticId === "string") return staticId; return uuid; } //#endregion export { useId$1 as useId }; //# sourceMappingURL=use-id.mjs.map