Skip to content

Commit f6c0b64

Browse files
committed
Another attempt
1 parent f2ac626 commit f6c0b64

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/core-react-interop.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
import { shortuuid } from "./core-utils";
22
const React = require("react");
33

4-
function getIdFn() {
5-
if (React.version.startsWith("18") && typeof React.useId !== "undefined") {
6-
return React.useId;
7-
}
8-
// @ts-ignore
9-
if (typeof React.unstable_useOpaqueIdentifier !== "undefined") {
10-
console.log("React 17 legacy");
11-
// @ts-ignore
12-
return React.unstable_useOpaqueIdentifier;
13-
}
14-
return () => `s${shortuuid()}`;
15-
}
4+
const idFn =
5+
React.version.startsWith("18") && typeof React.useId !== "undefined"
6+
? React.useId
7+
: typeof React.unstable_useOpaqueIdentifier !== "undefined"
8+
? React.unstable_useOpaqueIdentifier
9+
: () => `${shortuuid()}`;
1610

1711
export function useUniqueId(ssrEnabled: boolean) {
18-
const idFn = getIdFn();
1912
return `s${idFn().replace(/\:/g, "")}`;
2013
}

0 commit comments

Comments
 (0)