@ic-reactor/react 1.3.0 → 1.3.1

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.
@@ -123,7 +123,7 @@ const actorHooks = (actorManager) => {
123
123
  throw new Error("Args required");
124
124
  }
125
125
  attributes.validate((args.args || []));
126
- formRequired = false;
126
+ formRequired = args.refetchOnMount === false ? true : false;
127
127
  }
128
128
  catch (error) {
129
129
  refetchOnMount = false;
@@ -129,31 +129,33 @@ const useActor = (config) => {
129
129
  });
130
130
  }
131
131
  }), [canisterId, authenticating, didjsCanisterId]);
132
+ const initialActorManager = (0, react_1.useCallback)((idlFactory) => {
133
+ if (authenticating)
134
+ return;
135
+ const actorManager = (0, core_1.createActorManager)(Object.assign({ agentManager,
136
+ idlFactory,
137
+ canisterId }, actorConfig));
138
+ setActorManager(() => actorManager);
139
+ }, [canisterId, agentManager, authenticating]);
132
140
  (0, react_1.useEffect)(() => {
133
141
  if (maybeIdlFactory) {
134
- const actorManager = (0, core_1.createActorManager)(Object.assign({ agentManager, idlFactory: maybeIdlFactory, canisterId }, actorConfig));
135
- setActorManager(() => actorManager);
142
+ initialActorManager(maybeIdlFactory);
136
143
  }
137
144
  else {
138
145
  setActorManager(undefined);
139
146
  fetchCandid().then((idlFactory) => {
140
147
  if (!idlFactory)
141
148
  return;
142
- const actorManager = (0, core_1.createActorManager)(Object.assign({ agentManager,
143
- idlFactory,
144
- canisterId }, actorConfig));
145
- setActorManager(() => actorManager);
149
+ initialActorManager(idlFactory);
146
150
  });
147
151
  }
148
152
  return actorManager === null || actorManager === void 0 ? void 0 : actorManager.cleanup();
149
- }, [fetchCandid, maybeIdlFactory, canisterId, agentManager]);
153
+ }, [fetchCandid, maybeIdlFactory, initialActorManager]);
150
154
  const hooks = (0, react_1.useMemo)(() => {
151
- if (fetching)
152
- return null;
153
155
  if (!actorManager)
154
156
  return null;
155
157
  return (0, helpers_1.actorHooks)(actorManager);
156
- }, [canisterId, authenticating, actorManager, fetching]);
158
+ }, [actorManager]);
157
159
  return { hooks, authenticating, fetching, fetchError };
158
160
  };
159
161
  exports.useActor = useActor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ic-reactor/react",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
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,7 +35,7 @@
35
35
  "node": ">=10"
36
36
  },
37
37
  "dependencies": {
38
- "@ic-reactor/core": "^1.3.0",
38
+ "@ic-reactor/core": "^1.3.1",
39
39
  "zustand-utils": "^1.3"
40
40
  },
41
41
  "peerDependencies": {
@@ -47,5 +47,5 @@
47
47
  "react": ">=16.8",
48
48
  "zustand": "4.5"
49
49
  },
50
- "gitHead": "25043c2d1a78b97e327995abaf13835ac511e5d6"
50
+ "gitHead": "05130e2581edfafd6390cf04ba618cb084bafc31"
51
51
  }