MCPcopy Index your code
hub / github.com/editablejs/editable / useId

Function useId

packages/ui/src/hooks/use-id.ts:8–15  ·  view source on GitHub ↗
(deterministicId?: string)

Source from the content-addressed store, hash-verified

6let count = 0
7
8function useId(deterministicId?: string): string {
9 const [id, setId] = React.useState<string | undefined>(useReactId())
10 // React versions older than 18 will have client-side ids only.
11 useIsomorphicLayoutEffect(() => {
12 if (!deterministicId) setId(reactId => reactId ?? String(count++))
13 }, [deterministicId])
14 return deterministicId || (id ? `ea-ui-${id}` : '')
15}
16
17export { useId }

Callers 2

PopoverFunction · 0.90
MenuSubFunction · 0.90

Calls 1

StringFunction · 0.85

Tested by

no test coverage detected