@@ -6,9 +6,9 @@ import { useLayoutEffect } from "./useLayoutEffect";
66
77let serverHandoffComplete = false ;
88let id = 0 ;
9- function genId ( ) : string {
9+ function genId ( baseName : string ) : string {
1010 ++ id ;
11- return id . toString ( ) ;
11+ return baseName + '-' + id . toString ( ) ;
1212}
1313
1414// Workaround for https://github.com/webpack/webpack/issues/14814
@@ -28,14 +28,14 @@ const maybeReactUseId: undefined | (() => string) = (React as any)[
2828 * @see Docs https://reach.tech/auto-id
2929 */
3030
31- export function useId ( ) : string {
31+ export function useId ( baseName : string ) : string {
3232 if ( maybeReactUseId !== undefined ) {
3333 return maybeReactUseId ( ) ;
3434 }
3535
3636 // If this instance isn't part of the initial render, we don't have to do the
3737 // double render/patch-up dance. We can just generate the ID and return it.
38- const initialId = ( serverHandoffComplete ? genId ( ) : '' ) ;
38+ const initialId = ( serverHandoffComplete ? genId ( baseName ) : '' ) ;
3939 const [ id , setId ] = useState ( initialId ) ;
4040
4141 useLayoutEffect ( ( ) => {
@@ -44,7 +44,7 @@ export function useId(): string {
4444 // rendering flicker, though it'll make the first render slower (unlikely
4545 // to matter, but you're welcome to measure your app and let us know if
4646 // it's a problem).
47- setId ( genId ( ) ) ;
47+ setId ( genId ( baseName ) ) ;
4848 }
4949 } , [ id ] ) ;
5050
0 commit comments