@ic-reactor/react 1.7.8 → 1.7.9
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/hooks/types.d.ts
CHANGED
|
@@ -3,10 +3,12 @@ export interface UseActorParameters extends Omit<ActorManagerParameters, "idlFac
|
|
|
3
3
|
candidString?: string;
|
|
4
4
|
canisterId: CanisterId;
|
|
5
5
|
idlFactory?: IDL.InterfaceFactory;
|
|
6
|
+
disableAutoFetch?: boolean;
|
|
6
7
|
}
|
|
7
8
|
export interface UseActorReturn<A = BaseActor> {
|
|
8
9
|
hooks: ActorHooksReturnType<A> | null;
|
|
9
10
|
fetching: boolean;
|
|
10
11
|
fetchError: string | null;
|
|
11
12
|
authenticating: boolean;
|
|
13
|
+
initialActor: (idlFactory?: IDL.InterfaceFactory) => void;
|
|
12
14
|
}
|
package/dist/hooks/useActor.js
CHANGED
|
@@ -91,7 +91,7 @@ const agent_1 = require("../context/agent");
|
|
|
91
91
|
* ```
|
|
92
92
|
*/
|
|
93
93
|
const useActor = (config) => {
|
|
94
|
-
const { canisterId, candidString, idlFactory: maybeIdlFactory } = config, actorConfig = __rest(config, ["canisterId", "candidString", "idlFactory"]);
|
|
94
|
+
const { canisterId, candidString, idlFactory: maybeIdlFactory, disableAutoFetch } = config, actorConfig = __rest(config, ["canisterId", "candidString", "idlFactory", "disableAutoFetch"]);
|
|
95
95
|
if (!canisterId) {
|
|
96
96
|
throw new Error("canisterId is required");
|
|
97
97
|
}
|
|
@@ -150,7 +150,7 @@ const useActor = (config) => {
|
|
|
150
150
|
}
|
|
151
151
|
}), [candidString]);
|
|
152
152
|
const agentManager = (0, agent_1.useAgentManager)();
|
|
153
|
-
const
|
|
153
|
+
const initialActor = (0, react_1.useCallback)((idlFactory) => {
|
|
154
154
|
if (authenticating || !idlFactory)
|
|
155
155
|
return;
|
|
156
156
|
const actorManager = (0, core_1.createActorManager)(Object.assign({ agentManager,
|
|
@@ -162,7 +162,14 @@ const useActor = (config) => {
|
|
|
162
162
|
if (authenticating)
|
|
163
163
|
return;
|
|
164
164
|
if (maybeIdlFactory) {
|
|
165
|
-
|
|
165
|
+
initialActor(maybeIdlFactory);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (disableAutoFetch) {
|
|
169
|
+
setState({
|
|
170
|
+
fetchError: "Candid interface not fetched!",
|
|
171
|
+
fetching: false,
|
|
172
|
+
});
|
|
166
173
|
return;
|
|
167
174
|
}
|
|
168
175
|
if (!candidAdapter) {
|
|
@@ -175,8 +182,8 @@ const useActor = (config) => {
|
|
|
175
182
|
else {
|
|
176
183
|
idlFactory = yield fetchCandid();
|
|
177
184
|
}
|
|
178
|
-
|
|
179
|
-
}), [fetchCandid, evaluateCandid, maybeIdlFactory,
|
|
185
|
+
initialActor(idlFactory);
|
|
186
|
+
}), [fetchCandid, evaluateCandid, maybeIdlFactory, initialActor]);
|
|
180
187
|
(0, react_1.useEffect)(() => {
|
|
181
188
|
handleActorInitialization();
|
|
182
189
|
}, [handleActorInitialization]);
|
|
@@ -185,6 +192,6 @@ const useActor = (config) => {
|
|
|
185
192
|
return null;
|
|
186
193
|
return (0, helpers_1.actorHooks)(actorManager);
|
|
187
194
|
}, [actorManager]);
|
|
188
|
-
return { hooks, authenticating, fetching, fetchError };
|
|
195
|
+
return { hooks, authenticating, fetching, fetchError, initialActor };
|
|
189
196
|
};
|
|
190
197
|
exports.useActor = useActor;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ic-reactor/react",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.9",
|
|
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",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"react": ">=16.8",
|
|
48
48
|
"zustand": "4.5"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "b9697dc99434b48b39020450ef5fabe4611bda6b"
|
|
51
51
|
}
|