@ic-reactor/react 0.3.6 → 0.3.8
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/actor.js +3 -1
- package/dist/types.d.ts +2 -1
- package/package.json +3 -3
package/dist/hooks/actor.js
CHANGED
|
@@ -38,7 +38,7 @@ const getActorHooks = ({ methodFields, canisterId, actorStore, callMethod, }) =>
|
|
|
38
38
|
}, [methodFields, functionName]);
|
|
39
39
|
return field;
|
|
40
40
|
};
|
|
41
|
-
const useReActorCall = ({ onError, onSuccess, onLoading, args = [], functionName, }) => {
|
|
41
|
+
const useReActorCall = ({ onError, onSuccess, onLoading, args = [], functionName, throwOnError = false, }) => {
|
|
42
42
|
const [state, setState] = (0, react_1.useState)({
|
|
43
43
|
data: undefined,
|
|
44
44
|
error: undefined,
|
|
@@ -60,6 +60,8 @@ const getActorHooks = ({ methodFields, canisterId, actorStore, callMethod, }) =>
|
|
|
60
60
|
onError === null || onError === void 0 ? void 0 : onError(error);
|
|
61
61
|
onLoading === null || onLoading === void 0 ? void 0 : onLoading(false);
|
|
62
62
|
setState((prevState) => (Object.assign(Object.assign({}, prevState), { error: error, loading: false })));
|
|
63
|
+
if (throwOnError)
|
|
64
|
+
throw error;
|
|
63
65
|
}
|
|
64
66
|
}), [args, functionName, onError, onSuccess, onLoading]);
|
|
65
67
|
const field = useMethodField(functionName);
|
package/dist/types.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ export type ActorCallArgs<A, M extends keyof A> = {
|
|
|
4
4
|
functionName: M & string;
|
|
5
5
|
args?: ExtractActorMethodArgs<A[M]>;
|
|
6
6
|
onLoading?: (loading: boolean) => void;
|
|
7
|
-
onError?: (error: Error |
|
|
7
|
+
onError?: (error: Error | undefined) => void;
|
|
8
8
|
onSuccess?: (data: ExtractActorMethodReturnType<A[M]> | undefined) => void;
|
|
9
|
+
throwOnError?: boolean;
|
|
9
10
|
};
|
|
10
11
|
export type ActorHookState<A, M extends keyof A> = {
|
|
11
12
|
data: ExtractActorMethodReturnType<A[M]> | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ic-reactor/react",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "A React library for interacting with Dfinity actors",
|
|
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/store": "^0.3.
|
|
38
|
+
"@ic-reactor/store": "^0.3.5",
|
|
39
39
|
"zustand-utils": "^1.3"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"react": ">=16.8",
|
|
49
49
|
"zustand": "4.4"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "d3a581fb90bd9d225f2df3c1914d4a175b652b86"
|
|
52
52
|
}
|