Skip to content

Commit

Permalink
fix: compile error useId only available in react18
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeepc committed Aug 4, 2023
1 parent 518080e commit 6173450
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/common/useIdWithFallback.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright © 2023 Ory Corp
// SPDX-License-Identifier: Apache-2.0

import { useId } from "react"
import * as React from "react"

/**
* A function to obtain a unique ID. If react is available, this
Expand All @@ -11,7 +11,7 @@ import { useId } from "react"
*/
export const useIdWithFallback = () => {
try {
return useId()
return React.useId()
} catch (e) {
return Math.random().toString(36).substring(2)
}
Expand Down

0 comments on commit 6173450

Please sign in to comment.