Skip to content

Commit

Permalink
fix: compile error caused by useId only being available in react18 (#120
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jorgeepc authored Aug 8, 2023
1 parent 86fc13f commit 3c06879
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 3c06879

Please sign in to comment.