-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
149 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as React from 'react'; | ||
import canUseDom from 'rc-util/lib/Dom/canUseDom'; | ||
|
||
let uuid = 0; | ||
|
||
/** Is client side and not jsdom */ | ||
export const isBrowserClient = process.env.NODE_ENV !== 'test' && canUseDom(); | ||
|
||
/** Get unique id for accessibility usage */ | ||
function getUUID(): number | string { | ||
let retId: string | number; | ||
|
||
// Test never reach | ||
/* istanbul ignore if */ | ||
if (isBrowserClient) { | ||
retId = uuid; | ||
uuid += 1; | ||
} else { | ||
retId = 'TEST_OR_SSR'; | ||
} | ||
|
||
return retId; | ||
} | ||
|
||
export default (id?: string) => { | ||
// Inner id for accessibility usage. Only work in client side | ||
const [innerId, setInnerId] = React.useState<string>(); | ||
React.useEffect(() => { | ||
setInnerId(`rc_progress_${getUUID()}`); | ||
}, []); | ||
return id || innerId; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4f5f960
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: