Skip to content

Commit

Permalink
fix: replace crypto in useNinjaId
Browse files Browse the repository at this point in the history
close #120
  • Loading branch information
stafyniaksacha committed May 2, 2024
1 parent 2a2b889 commit 96e8d5b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions composables/input-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ export function useNinjaId(id?: MaybeRefOrGetter<string | undefined>) {
watch(
() => toValue(id),
(value) => {
internal.value = value || `nui-input-${crypto.randomUUID()}`
internal.value =
value || `nui-input-${Math.random().toString(36).slice(2)}`
},
)

// only generate identifier on client to avoid hydration issues
onMounted(() => {
if (!internal.value) {
internal.value = `nui-input-${crypto.randomUUID()}`
internal.value = `nui-input-${Math.random().toString(36).slice(2)}`
}
})

Expand Down

0 comments on commit 96e8d5b

Please sign in to comment.