@ic-reactor/react 1.2.0 → 1.2.2
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.
|
@@ -47,10 +47,13 @@ const DEFAULT_STATE = {
|
|
|
47
47
|
* Each hook is designed to simplify the process of interacting with actors in IC projects by abstracting away the complexity of state management, error handling, and method invocation.
|
|
48
48
|
*/
|
|
49
49
|
const actorHooks = (actorManager) => {
|
|
50
|
-
const { actorStore, canisterId, visitFunction, extractInterface, callMethod, initialize, } = actorManager;
|
|
50
|
+
const { actorStore, canisterId, visitFunction, extractInterface, extractMethodNames, callMethod, initialize, } = actorManager;
|
|
51
51
|
const useActorState = () => (Object.assign(Object.assign({}, (0, zustand_1.useStore)(actorStore)), { canisterId }));
|
|
52
|
+
const useMethodNames = () => {
|
|
53
|
+
return react_1.default.useMemo(() => extractMethodNames(), []);
|
|
54
|
+
};
|
|
52
55
|
const useActorInterface = () => {
|
|
53
|
-
return extractInterface();
|
|
56
|
+
return react_1.default.useMemo(() => extractInterface(), []);
|
|
54
57
|
};
|
|
55
58
|
const useVisitService = () => {
|
|
56
59
|
return visitFunction;
|
|
@@ -116,6 +119,7 @@ const actorHooks = (actorManager) => {
|
|
|
116
119
|
return {
|
|
117
120
|
initialize,
|
|
118
121
|
useMethod,
|
|
122
|
+
useMethodNames,
|
|
119
123
|
useQueryCall,
|
|
120
124
|
useUpdateCall,
|
|
121
125
|
useActorState,
|
|
@@ -39,6 +39,7 @@ function extractActorContext(actorContext) {
|
|
|
39
39
|
return context;
|
|
40
40
|
};
|
|
41
41
|
const initialize = () => useActorContext().initialize();
|
|
42
|
+
const useMethodNames = () => useActorContext().useMethodNames();
|
|
42
43
|
const useActorState = () => useActorContext().useActorState();
|
|
43
44
|
const useMethod = (args) => useActorContext().useMethod(args);
|
|
44
45
|
const useQueryCall = (args) => useActorContext().useQueryCall(args);
|
|
@@ -49,6 +50,7 @@ function extractActorContext(actorContext) {
|
|
|
49
50
|
return {
|
|
50
51
|
useActorState,
|
|
51
52
|
useMethod,
|
|
53
|
+
useMethodNames,
|
|
52
54
|
useQueryCall,
|
|
53
55
|
useUpdateCall,
|
|
54
56
|
useVisitMethod,
|
package/dist/helpers/types.d.ts
CHANGED
|
@@ -88,6 +88,7 @@ export interface ActorHooksReturnType<A = BaseActor> {
|
|
|
88
88
|
initialize: () => Promise<void>;
|
|
89
89
|
useActorState: () => UseActorState;
|
|
90
90
|
useActorInterface: () => ServiceClass;
|
|
91
|
+
useMethodNames: () => FunctionName<A>[];
|
|
91
92
|
useMethod: UseMethod<A>;
|
|
92
93
|
useQueryCall: UseQueryCall<A>;
|
|
93
94
|
useUpdateCall: UseUpdateCall<A>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMethodNames = void 0;
|
|
4
|
+
const hooks_1 = require("./hooks");
|
|
5
|
+
/**
|
|
6
|
+
* Hook for accessing the method names of an actor.
|
|
7
|
+
*
|
|
8
|
+
* @returns An array of method names for the actor.
|
|
9
|
+
*/
|
|
10
|
+
exports.useMethodNames = hooks_1.ActorHooks.useMethodNames;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ic-reactor/react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "A React library for interacting with Internet Computer canisters",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -35,20 +35,17 @@
|
|
|
35
35
|
"node": ">=10"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@dfinity/auth-client": ">=1.0",
|
|
40
|
-
"@dfinity/candid": ">=1.0",
|
|
41
|
-
"@dfinity/principal": ">=1.0",
|
|
42
|
-
"@ic-reactor/core": "^1.2.0",
|
|
38
|
+
"@ic-reactor/core": "^1.2.2",
|
|
43
39
|
"zustand-utils": "^1.3"
|
|
44
40
|
},
|
|
45
41
|
"peerDependencies": {
|
|
46
42
|
"@dfinity/agent": ">=1.0",
|
|
47
43
|
"@dfinity/auth-client": ">=1.0",
|
|
48
44
|
"@dfinity/candid": ">=1.0",
|
|
45
|
+
"@dfinity/identity": ">=1.0",
|
|
49
46
|
"@dfinity/principal": ">=1.0",
|
|
50
47
|
"react": ">=16.8",
|
|
51
48
|
"zustand": "4.5"
|
|
52
49
|
},
|
|
53
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "9d79b40cd3306d2f363ac7ab3a6b9815300648d6"
|
|
54
51
|
}
|