@xyo-network/react-node 2.45.0-rc.3 → 2.45.0-rc.4
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/dist/cjs/hooks/createUseModuleHook.js +6 -3
- package/dist/cjs/hooks/createUseModuleHook.js.map +1 -1
- package/dist/docs.json +356 -155
- package/dist/esm/hooks/createUseModuleHook.js +6 -3
- package/dist/esm/hooks/createUseModuleHook.js.map +1 -1
- package/dist/types/hooks/createUseModuleHook.d.ts +1 -0
- package/dist/types/hooks/createUseModuleHook.d.ts.map +1 -1
- package/dist/types/hooks/useModule.d.ts +11 -0
- package/dist/types/hooks/useModule.d.ts.map +1 -1
- package/dist/types/hooks/useNode.d.ts +1 -0
- package/dist/types/hooks/useNode.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/hooks/createUseModuleHook.tsx +10 -3
|
@@ -6,7 +6,10 @@ const tslib_1 = require("tslib");
|
|
|
6
6
|
const react_shared_1 = require("@xylabs/react-shared");
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const createUseModuleHook = (wrapFunc, useNodeHook) => {
|
|
9
|
-
function use(
|
|
9
|
+
function use(nameOrAddressOrWrapOrAccount, wrap = false) {
|
|
10
|
+
const shouldWrap = typeof nameOrAddressOrWrapOrAccount === 'boolean' ? nameOrAddressOrWrapOrAccount : wrap;
|
|
11
|
+
const account = typeof nameOrAddressOrWrapOrAccount === 'object' ? nameOrAddressOrWrapOrAccount : typeof wrap === 'boolean' ? undefined : wrap;
|
|
12
|
+
const nameOrAddress = typeof nameOrAddressOrWrapOrAccount === 'string' ? nameOrAddressOrWrapOrAccount : undefined;
|
|
10
13
|
const [node, nodeError] = useNodeHook(nameOrAddress, true);
|
|
11
14
|
const [module, setModule] = (0, react_1.useState)();
|
|
12
15
|
const [error, setError] = (0, react_1.useState)();
|
|
@@ -20,7 +23,7 @@ const createUseModuleHook = (wrapFunc, useNodeHook) => {
|
|
|
20
23
|
}
|
|
21
24
|
else {
|
|
22
25
|
const module = yield (node === null || node === void 0 ? void 0 : node.resolve(nameOrAddress));
|
|
23
|
-
const finalModule =
|
|
26
|
+
const finalModule = shouldWrap ? wrapFunc(module, account) : module;
|
|
24
27
|
if (mounted()) {
|
|
25
28
|
setModule(finalModule);
|
|
26
29
|
}
|
|
@@ -32,7 +35,7 @@ const createUseModuleHook = (wrapFunc, useNodeHook) => {
|
|
|
32
35
|
setModule(undefined);
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
|
-
}), [wrap, node, nameOrAddress, nodeError]);
|
|
38
|
+
}), [wrap, node, nameOrAddress, nodeError, shouldWrap, account]);
|
|
36
39
|
return [module, error];
|
|
37
40
|
}
|
|
38
41
|
return use;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createUseModuleHook.js","sourceRoot":"","sources":["../../../src/hooks/createUseModuleHook.tsx"],"names":[],"mappings":";;;;AAAA,+CAA+C;AAC/C,uDAAqD;AAIrD,iCAAgC;AAOzB,MAAM,mBAAmB,GAAG,CAKjC,QAAmB,EACnB,WAA4G,EAC5G,EAAE;
|
|
1
|
+
{"version":3,"file":"createUseModuleHook.js","sourceRoot":"","sources":["../../../src/hooks/createUseModuleHook.tsx"],"names":[],"mappings":";;;;AAAA,+CAA+C;AAC/C,uDAAqD;AAIrD,iCAAgC;AAOzB,MAAM,mBAAmB,GAAG,CAKjC,QAAmB,EACnB,WAA4G,EAC5G,EAAE;IAMF,SAAS,GAAG,CACV,4BAAyD,EACzD,OAA0B,KAAK;QAE/B,MAAM,UAAU,GAAG,OAAO,4BAA4B,KAAK,SAAS,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,IAAI,CAAA;QAC1G,MAAM,OAAO,GAAG,OAAO,4BAA4B,KAAK,QAAQ,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAA;QAC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