Skip to content

Commit c2c2243

Browse files
authored
fix(uuid): Use uuid package for unique class names (#566)
1 parent 9acc591 commit c2c2243

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

Diff for: package.json

+12-11
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
"react-dom": ">=16.0.0"
5353
},
5454
"dependencies": {
55-
"prop-types": "^15.7.2"
55+
"prop-types": "^15.7.2",
56+
"uuid": "^7.0.2"
5657
},
5758
"devDependencies": {
5859
"@babel/cli": "^7.7.4",
@@ -80,22 +81,20 @@
8081
"enzyme": "^2.3.0",
8182
"enzyme-adapter-react-16": "^1.15.2",
8283
"eslint": "^6.8.0",
83-
"eslint-config-standard": "^14.1.0",
84-
"eslint-config-standard-react": "^9.2.0",
8584
"eslint-config-jss": "5.0.1",
8685
"eslint-config-prettier": "6.10.0",
86+
"eslint-config-standard": "^14.1.0",
87+
"eslint-config-standard-react": "^9.2.0",
8788
"eslint-plugin-import": "^2.18.2",
8889
"eslint-plugin-node": "^10.0.0",
90+
"eslint-plugin-prettier": "3.1.2",
8991
"eslint-plugin-promise": "^4.2.1",
9092
"eslint-plugin-react": "^7.16.0",
9193
"eslint-plugin-standard": "^4.0.1",
92-
"eslint-plugin-prettier": "3.1.2",
93-
"stylelint": "13.2.0",
94-
"stylelint-config-standard": "20.0.0",
95-
"prettier": "1.19.1",
9694
"gh-pages": "1.1.0",
9795
"github-changes": "^1.1.2",
9896
"http-server": "^0.11.1",
97+
"ignore-styles": "5.0.1",
9998
"jsdom": "^9.2.1",
10099
"mocha": "^5.2.0",
101100
"mocha-each": "^2.0.1",
@@ -104,24 +103,26 @@
104103
"npm-run-all": "^4.1.5",
105104
"postcss-nested": "^4.2.1",
106105
"postcss-simple-vars": "^5.0.2",
106+
"prettier": "1.19.1",
107107
"react": "^16.4.1",
108108
"react-addons-test-utils": "^15.1.0",
109109
"react-dom": "^16.4.1",
110110
"rimraf": "^3.0.0",
111111
"rollup": "^1.27.5",
112112
"rollup-plugin-babel": "^4.3.3",
113+
"rollup-plugin-eslint": "7.0.0",
113114
"rollup-plugin-peer-deps-external": "^2.2.0",
114115
"rollup-plugin-postcss": "^2.0.3",
115116
"rollup-plugin-sass": "^1.2.2",
116-
"rollup-plugin-url": "^3.0.1",
117-
"rollup-plugin-eslint": "7.0.0",
118117
"rollup-plugin-stylelint": "1.0.0",
118+
"rollup-plugin-url": "^3.0.1",
119119
"semantic-release": "15.1.5",
120120
"snazzy": "^2.0.1",
121121
"standard": "^5.2.2",
122+
"stylelint": "13.2.0",
123+
"stylelint-config-standard": "20.0.0",
122124
"uglifyjs": "^2.4.10",
123-
"watchify": "^3.11.1",
124-
"ignore-styles": "5.0.1"
125+
"watchify": "^3.11.1"
125126
},
126127
"files": [
127128
"dist"

Diff for: src/utils/uuid.js

+2-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
1-
/**
2-
* By w3resource, 2020, https://www.w3resource.com/javascript-exercises/javascript-math-exercise-23.php
3-
*/
1+
import { v4 as uuid } from "uuid";
42

53
export function generateUUID(){
6-
let dt = new Date().getTime();
7-
8-
let uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
9-
const r = (dt + Math.random()*16)%16 | 0;
10-
dt = Math.floor(dt/16);
11-
return (c === "x" ? r :(r&0x3|0x8)).toString(16);
12-
});
13-
14-
uuid = "t" + uuid.substring(1, uuid.length); // CSS does not work correctly with classes starting with a numeric character
15-
16-
return uuid;
4+
return "t" + uuid();
175
}

Diff for: yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -11955,6 +11955,11 @@ uuid@^3.3.2:
1195511955
version "3.3.3"
1195611956
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.3.tgz#4568f0216e78760ee1dbf3a4d2cf53e224112866"
1195711957

11958+
uuid@^7.0.2:
11959+
version "7.0.2"
11960+
resolved "https://registry.yarnpkg.org/uuid/-/uuid-7.0.2.tgz#7ff5c203467e91f5e0d85cfcbaaf7d2ebbca9be6"
11961+
integrity sha512-vy9V/+pKG+5ZTYKf+VcphF5Oc6EFiu3W8Nv3P3zIh0EqVI80ZxOzuPfe9EHjkFNvf8+xuTHVeei4Drydlx4zjw==
11962+
1195811963
v8-compile-cache@^2.0.3, v8-compile-cache@^2.1.0:
1195911964
version "2.1.0"
1196011965
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz#e14de37b31a6d194f5690d67efc4e7f6fc6ab30e"

0 commit comments

Comments
 (0)