forked from ReactTooltip/react-tooltip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(uuid): Use uuid package for unique class names (ReactTooltip#566)
- Loading branch information
Showing
3 changed files
with
19 additions
and
25 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 |
---|---|---|
@@ -1,17 +1,5 @@ | ||
/** | ||
* By w3resource, 2020, https://www.w3resource.com/javascript-exercises/javascript-math-exercise-23.php | ||
*/ | ||
import { v4 as uuid } from "uuid"; | ||
|
||
export function generateUUID(){ | ||
let dt = new Date().getTime(); | ||
|
||
let uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => { | ||
const r = (dt + Math.random()*16)%16 | 0; | ||
dt = Math.floor(dt/16); | ||
return (c === "x" ? r :(r&0x3|0x8)).toString(16); | ||
}); | ||
|
||
uuid = "t" + uuid.substring(1, uuid.length); // CSS does not work correctly with classes starting with a numeric character | ||
|
||
return uuid; | ||
return "t" + uuid(); | ||
} |
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