@superbia/untrue 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +0 -0
- package/README.md +0 -0
- package/index.js +2 -1
- package/package.json +3 -3
- package/src/DocumentContext.js +0 -0
- package/src/RequestContext.js +0 -0
- package/src/SuperbiaContext.js +0 -0
- package/src/{RequestWrapper.js → SuperbiaUntrue.js} +23 -7
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superbia/untrue",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Integrate Superbia and Untrue.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
],
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"untrue": "^
|
|
16
|
+
"untrue": "^5.7.2"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"uuid": "^
|
|
19
|
+
"uuid": "^10.0.0"
|
|
20
20
|
}
|
|
21
21
|
}
|
package/src/DocumentContext.js
CHANGED
|
File without changes
|
package/src/RequestContext.js
CHANGED
|
File without changes
|
package/src/SuperbiaContext.js
CHANGED
|
File without changes
|
|
@@ -1,8 +1,28 @@
|
|
|
1
|
-
import { Component,
|
|
1
|
+
import $, { Component, Hook } from "untrue";
|
|
2
2
|
|
|
3
3
|
import { v4 as uuid } from "uuid";
|
|
4
4
|
|
|
5
|
-
export class
|
|
5
|
+
export default class SuperbiaUntrue {
|
|
6
|
+
static useRequestKey(requestKeyExtractor = null) {
|
|
7
|
+
return Hook.useMemo(() => {
|
|
8
|
+
let key = null;
|
|
9
|
+
|
|
10
|
+
if (requestKeyExtractor !== null) {
|
|
11
|
+
if (typeof requestKeyExtractor === "function") {
|
|
12
|
+
key = requestKeyExtractor();
|
|
13
|
+
} else {
|
|
14
|
+
key = requestKeyExtractor;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (key === null) {
|
|
19
|
+
key = uuid();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return key;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
6
26
|
static wrapRequester(Child, requestKeyExtractor = null) {
|
|
7
27
|
return class RequestComponent extends Component {
|
|
8
28
|
constructor(props) {
|
|
@@ -28,11 +48,7 @@ export class RequestWrapper {
|
|
|
28
48
|
render() {
|
|
29
49
|
const { children, ...props } = this.props;
|
|
30
50
|
|
|
31
|
-
return
|
|
32
|
-
Child,
|
|
33
|
-
{ ...props, requestKey: this.requestKey },
|
|
34
|
-
children
|
|
35
|
-
);
|
|
51
|
+
return $(Child, { ...props, requestKey: this.requestKey }, children);
|
|
36
52
|
}
|
|
37
53
|
};
|
|
38
54
|
}
|