Skip to content

Commit

Permalink
fix(runtime-core): make useId() always return a string
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Sep 23, 2024
1 parent 5e88985 commit a177092
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/runtime-core/src/helpers/useId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
} from '../component'
import { warn } from '../warning'

export function useId(): string | undefined {
export function useId(): string {
const i = getCurrentInstance()
if (i) {
return (i.appContext.config.idPrefix || 'v') + '-' + i.ids[0] + i.ids[1]++
Expand All @@ -14,6 +14,7 @@ export function useId(): string | undefined {
`instance to be associated with.`,
)
}
return ''
}

/**
Expand Down

0 comments on commit a177092

Please sign in to comment.