@faasjs/react 0.0.3-beta.19 → 0.0.3-beta.20
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/index.d.ts +1 -0
- package/dist/index.js +7 -2
- package/dist/index.mjs +9 -3
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ type FaasDataInjection<Data = any> = {
|
|
|
21
21
|
};
|
|
22
22
|
type FaasDataWrapperProps<PathOrData extends FaasAction> = {
|
|
23
23
|
render?(args: FaasDataInjection<FaasData<PathOrData>>): JSX.Element | JSX.Element[];
|
|
24
|
+
children?: JSX.Element;
|
|
24
25
|
fallback?: JSX.Element | false;
|
|
25
26
|
action: string;
|
|
26
27
|
params?: FaasParams<PathOrData>;
|
package/dist/index.js
CHANGED
|
@@ -117,6 +117,7 @@ function FaasReactClient({
|
|
|
117
117
|
params,
|
|
118
118
|
fallback,
|
|
119
119
|
render,
|
|
120
|
+
children,
|
|
120
121
|
onDataChange,
|
|
121
122
|
data,
|
|
122
123
|
setData
|
|
@@ -134,8 +135,12 @@ function FaasReactClient({
|
|
|
134
135
|
if (onDataChange)
|
|
135
136
|
onDataChange(request);
|
|
136
137
|
}, [JSON.stringify(request.data)]);
|
|
137
|
-
if (loaded)
|
|
138
|
-
|
|
138
|
+
if (loaded) {
|
|
139
|
+
if (children)
|
|
140
|
+
return (0, import_react.cloneElement)(children, request);
|
|
141
|
+
if (render)
|
|
142
|
+
return render(request);
|
|
143
|
+
}
|
|
139
144
|
return fallback || null;
|
|
140
145
|
}
|
|
141
146
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
useState,
|
|
7
7
|
useEffect,
|
|
8
|
-
createElement
|
|
8
|
+
createElement,
|
|
9
|
+
cloneElement
|
|
9
10
|
} from "react";
|
|
10
11
|
var clients = {};
|
|
11
12
|
function FaasReactClient({
|
|
@@ -95,6 +96,7 @@ function FaasReactClient({
|
|
|
95
96
|
params,
|
|
96
97
|
fallback,
|
|
97
98
|
render,
|
|
99
|
+
children,
|
|
98
100
|
onDataChange,
|
|
99
101
|
data,
|
|
100
102
|
setData
|
|
@@ -112,8 +114,12 @@ function FaasReactClient({
|
|
|
112
114
|
if (onDataChange)
|
|
113
115
|
onDataChange(request);
|
|
114
116
|
}, [JSON.stringify(request.data)]);
|
|
115
|
-
if (loaded)
|
|
116
|
-
|
|
117
|
+
if (loaded) {
|
|
118
|
+
if (children)
|
|
119
|
+
return cloneElement(children, request);
|
|
120
|
+
if (render)
|
|
121
|
+
return render(request);
|
|
122
|
+
}
|
|
117
123
|
return fallback || null;
|
|
118
124
|
}
|
|
119
125
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/react",
|
|
3
|
-
"version": "0.0.3-beta.
|
|
3
|
+
"version": "0.0.3-beta.20",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@faasjs/browser": "^0.0.3-beta.
|
|
27
|
-
"@faasjs/types": "^0.0.3-beta.
|
|
26
|
+
"@faasjs/browser": "^0.0.3-beta.20",
|
|
27
|
+
"@faasjs/types": "^0.0.3-beta.20",
|
|
28
28
|
"react": "*"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|