File tree Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Original file line number Diff line number Diff line change 1
1
import { shortuuid } from "./core-utils" ;
2
2
const React = require ( "react" ) ;
3
3
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 ( ) } ` ;
16
10
17
11
export function useUniqueId ( ssrEnabled : boolean ) {
18
- const idFn = getIdFn ( ) ;
19
12
return `s${ idFn ( ) . replace ( / \: / g, "" ) } ` ;
20
13
}
You can’t perform that action at this time.
0 commit comments