@faasjs/react 2.6.1 → 2.8.0

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/README.md CHANGED
@@ -54,6 +54,7 @@ const client = FaasReactClient({
54
54
  - [FaasParams](type-aliases/FaasParams.md)
55
55
  - [FaasReactClientInstance](type-aliases/FaasReactClientInstance.md)
56
56
  - [FaasReactClientOptions](type-aliases/FaasReactClientOptions.md)
57
+ - [OptionalWrapperProps](type-aliases/OptionalWrapperProps.md)
57
58
  - [Options](type-aliases/Options.md)
58
59
  - [ResponseHeaders](type-aliases/ResponseHeaders.md)
59
60
  - [useFaasOptions](type-aliases/useFaasOptions.md)
@@ -62,9 +63,11 @@ const client = FaasReactClient({
62
63
 
63
64
  - [FaasDataWrapper](functions/FaasDataWrapper.md)
64
65
  - [FaasReactClient](functions/FaasReactClient.md)
66
+ - [OptionalWrapper](functions/OptionalWrapper.md)
65
67
  - [createSplitedContext](functions/createSplitedContext.md)
66
68
  - [createSplittingContext](functions/createSplittingContext.md)
67
69
  - [faas](functions/faas.md)
68
70
  - [getClient](functions/getClient.md)
69
71
  - [useConstant](functions/useConstant.md)
70
72
  - [useFaas](functions/useFaas.md)
73
+ - [withFaasData](functions/withFaasData.md)
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
- import { FaasAction as FaasAction$1, FaasParams as FaasParams$1, FaasData as FaasData$1 } from '@faasjs/types';
1
+ import { FaasAction, FaasParams, FaasData } from '@faasjs/types';
2
2
  export { FaasAction, FaasData, FaasParams } from '@faasjs/types';
3
3
  import { Options, ResponseError, Response as Response$1 } from '@faasjs/browser';
4
4
  export { Options, Response, ResponseError, ResponseHeaders } from '@faasjs/browser';
5
5
  import * as react from 'react';
6
- import { ReactNode, ReactElement, Component } from 'react';
6
+ import { ReactNode, ReactElement, Component, ComponentProps, ComponentType } from 'react';
7
7
  import * as react_jsx_runtime from 'react/jsx-runtime';
8
8
 
9
9
  /**
@@ -119,6 +119,7 @@ type FaasDataWrapperProps<PathOrData extends FaasAction> = {
119
119
  data?: FaasData<PathOrData>
120
120
  /** use custom setData, should work with data */
121
121
  setData?: React.Dispatch<React.SetStateAction<FaasData<PathOrData>>>
122
+ domain?: string
122
123
  }
123
124
 
124
125
  type useFaasOptions<PathOrData extends FaasAction> = {
@@ -153,6 +154,7 @@ type FaasReactClientOptions = {
153
154
  declare function FaasReactClient({ domain, options, onError, }: FaasReactClientOptions): FaasReactClientInstance;
154
155
  /**
155
156
  * Get FaasReactClient instance
157
+ *
156
158
  * @param domain {string} empty string for default domain
157
159
  * @returns {FaasReactClientInstance}
158
160
  *
@@ -178,7 +180,7 @@ declare function getClient(domain?: string): FaasReactClientInstance;
178
180
  * })
179
181
  * ```
180
182
  */
181
- declare function faas<PathOrData extends FaasAction$1>(action: string | PathOrData, params: FaasParams$1<PathOrData>): Promise<Response$1<FaasData$1<PathOrData>>>;
183
+ declare function faas<PathOrData extends FaasAction>(action: string | PathOrData, params: FaasParams<PathOrData>): Promise<Response$1<FaasData<PathOrData>>>;
182
184
  /**
183
185
  * Request faas server with React hook
184
186
  *
@@ -194,28 +196,7 @@ declare function faas<PathOrData extends FaasAction$1>(action: string | PathOrDa
194
196
  * }
195
197
  * ```
196
198
  */
197
- declare function useFaas<PathOrData extends FaasAction$1>(action: string | PathOrData, defaultParams: FaasParams$1<PathOrData>, options?: useFaasOptions<PathOrData>): FaasDataInjection<FaasData$1<PathOrData>>;
198
- /**
199
- * A data wrapper for react components
200
- *
201
- * @returns {JSX.Element}
202
- *
203
- * @example
204
- * ```tsx
205
- * <FaasDataWrapper<{
206
- * id: string
207
- * title: string
208
- * }>
209
- * action='post/get'
210
- * params={ { id: 1 } }
211
- * render={ ({ data }) => <h1>{ data.title }</h1> }
212
- * />
213
- * ```
214
- */
215
- declare function FaasDataWrapper<PathOrData extends FaasAction$1>(props: FaasDataWrapperProps<PathOrData>): JSX.Element;
216
- declare namespace FaasDataWrapper {
217
- var whyDidYouRender: boolean;
218
- }
199
+ declare function useFaas<PathOrData extends FaasAction>(action: string | PathOrData, defaultParams: FaasParams<PathOrData>, options?: useFaasOptions<PathOrData>): FaasDataInjection<FaasData<PathOrData>>;
219
200
 
220
201
  interface ErrorBoundaryProps {
221
202
  children?: ReactNode;
@@ -240,4 +221,48 @@ declare class ErrorBoundary extends Component<ErrorBoundaryProps, {
240
221
  render(): string | number | boolean | Iterable<ReactNode> | react_jsx_runtime.JSX.Element;
241
222
  }
242
223
 
243
- export { ErrorBoundary, type ErrorBoundaryProps, type ErrorChildrenProps, type FaasDataInjection, FaasDataWrapper, type FaasDataWrapperProps, FaasReactClient, type FaasReactClientInstance, type FaasReactClientOptions, createSplitedContext, createSplittingContext, faas, getClient, useConstant, useFaas, type useFaasOptions };
224
+ declare function FaasDataWrapper<PathOrData extends FaasAction>({ action, params, fallback, render, children, onDataChange, data, setData, domain, }: FaasDataWrapperProps<PathOrData>): JSX.Element;
225
+ declare namespace FaasDataWrapper {
226
+ var whyDidYouRender: boolean;
227
+ }
228
+ /**
229
+ * HOC to wrap a component with FaasDataWrapper
230
+ *
231
+ * @example
232
+ * ```tsx
233
+ * const MyComponent = withFaasData(MyComponent, { action: 'test', params: { a: 1 } })
234
+ * ```
235
+ */
236
+ declare function withFaasData<TComponent extends React.FC<any>, PathOrData extends FaasAction>(Component: TComponent, faasProps: FaasDataWrapperProps<PathOrData>): (props: Omit<ComponentProps<TComponent>, "data">) => react_jsx_runtime.JSX.Element;
237
+
238
+ type OptionalWrapperProps<TWrapper extends ComponentType<{
239
+ children: ReactNode;
240
+ }> = any> = {
241
+ condition: boolean;
242
+ Wrapper: TWrapper;
243
+ wrapperProps?: ComponentProps<TWrapper>;
244
+ children: ReactNode;
245
+ };
246
+ /**
247
+ * A wrapper component that conditionally wraps its children with a provided wrapper component.
248
+ *
249
+ * @example
250
+ * ```tsx
251
+ * import { OptionalWrapper } from '@faasjs/react'
252
+ *
253
+ * const Wrapper = ({ children }: { children: React.ReactNode }) => (
254
+ * <div className='wrapper'>{children}</div>
255
+ * )
256
+ *
257
+ * const App = () => (
258
+ * <OptionalWrapper condition={true} Wrapper={Wrapper}>
259
+ * <span>Test</span>
260
+ * </OptionalWrapper>
261
+ * )
262
+ * ```
263
+ */
264
+ declare const OptionalWrapper: React.FC<OptionalWrapperProps> & {
265
+ whyDidYouRender: boolean;
266
+ };
267
+
268
+ export { ErrorBoundary, type ErrorBoundaryProps, type ErrorChildrenProps, type FaasDataInjection, FaasDataWrapper, type FaasDataWrapperProps, FaasReactClient, type FaasReactClientInstance, type FaasReactClientOptions, OptionalWrapper, type OptionalWrapperProps, createSplitedContext, createSplittingContext, faas, getClient, useConstant, useFaas, type useFaasOptions, withFaasData };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { FaasAction as FaasAction$1, FaasParams as FaasParams$1, FaasData as FaasData$1 } from '@faasjs/types';
1
+ import { FaasAction, FaasParams, FaasData } from '@faasjs/types';
2
2
  export { FaasAction, FaasData, FaasParams } from '@faasjs/types';
3
3
  import { Options, ResponseError, Response as Response$1 } from '@faasjs/browser';
4
4
  export { Options, Response, ResponseError, ResponseHeaders } from '@faasjs/browser';
5
5
  import * as react from 'react';
6
- import { ReactNode, ReactElement, Component } from 'react';
6
+ import { ReactNode, ReactElement, Component, ComponentProps, ComponentType } from 'react';
7
7
  import * as react_jsx_runtime from 'react/jsx-runtime';
8
8
 
9
9
  /**
@@ -119,6 +119,7 @@ type FaasDataWrapperProps<PathOrData extends FaasAction> = {
119
119
  data?: FaasData<PathOrData>
120
120
  /** use custom setData, should work with data */
121
121
  setData?: React.Dispatch<React.SetStateAction<FaasData<PathOrData>>>
122
+ domain?: string
122
123
  }
123
124
 
124
125
  type useFaasOptions<PathOrData extends FaasAction> = {
@@ -153,6 +154,7 @@ type FaasReactClientOptions = {
153
154
  declare function FaasReactClient({ domain, options, onError, }: FaasReactClientOptions): FaasReactClientInstance;
154
155
  /**
155
156
  * Get FaasReactClient instance
157
+ *
156
158
  * @param domain {string} empty string for default domain
157
159
  * @returns {FaasReactClientInstance}
158
160
  *
@@ -178,7 +180,7 @@ declare function getClient(domain?: string): FaasReactClientInstance;
178
180
  * })
179
181
  * ```
180
182
  */
181
- declare function faas<PathOrData extends FaasAction$1>(action: string | PathOrData, params: FaasParams$1<PathOrData>): Promise<Response$1<FaasData$1<PathOrData>>>;
183
+ declare function faas<PathOrData extends FaasAction>(action: string | PathOrData, params: FaasParams<PathOrData>): Promise<Response$1<FaasData<PathOrData>>>;
182
184
  /**
183
185
  * Request faas server with React hook
184
186
  *
@@ -194,28 +196,7 @@ declare function faas<PathOrData extends FaasAction$1>(action: string | PathOrDa
194
196
  * }
195
197
  * ```
196
198
  */
197
- declare function useFaas<PathOrData extends FaasAction$1>(action: string | PathOrData, defaultParams: FaasParams$1<PathOrData>, options?: useFaasOptions<PathOrData>): FaasDataInjection<FaasData$1<PathOrData>>;
198
- /**
199
- * A data wrapper for react components
200
- *
201
- * @returns {JSX.Element}
202
- *
203
- * @example
204
- * ```tsx
205
- * <FaasDataWrapper<{
206
- * id: string
207
- * title: string
208
- * }>
209
- * action='post/get'
210
- * params={ { id: 1 } }
211
- * render={ ({ data }) => <h1>{ data.title }</h1> }
212
- * />
213
- * ```
214
- */
215
- declare function FaasDataWrapper<PathOrData extends FaasAction$1>(props: FaasDataWrapperProps<PathOrData>): JSX.Element;
216
- declare namespace FaasDataWrapper {
217
- var whyDidYouRender: boolean;
218
- }
199
+ declare function useFaas<PathOrData extends FaasAction>(action: string | PathOrData, defaultParams: FaasParams<PathOrData>, options?: useFaasOptions<PathOrData>): FaasDataInjection<FaasData<PathOrData>>;
219
200
 
220
201
  interface ErrorBoundaryProps {
221
202
  children?: ReactNode;
@@ -240,4 +221,48 @@ declare class ErrorBoundary extends Component<ErrorBoundaryProps, {
240
221
  render(): string | number | boolean | Iterable<ReactNode> | react_jsx_runtime.JSX.Element;
241
222
  }
242
223
 
243
- export { ErrorBoundary, type ErrorBoundaryProps, type ErrorChildrenProps, type FaasDataInjection, FaasDataWrapper, type FaasDataWrapperProps, FaasReactClient, type FaasReactClientInstance, type FaasReactClientOptions, createSplitedContext, createSplittingContext, faas, getClient, useConstant, useFaas, type useFaasOptions };
224
+ declare function FaasDataWrapper<PathOrData extends FaasAction>({ action, params, fallback, render, children, onDataChange, data, setData, domain, }: FaasDataWrapperProps<PathOrData>): JSX.Element;
225
+ declare namespace FaasDataWrapper {
226
+ var whyDidYouRender: boolean;
227
+ }
228
+ /**
229
+ * HOC to wrap a component with FaasDataWrapper
230
+ *
231
+ * @example
232
+ * ```tsx
233
+ * const MyComponent = withFaasData(MyComponent, { action: 'test', params: { a: 1 } })
234
+ * ```
235
+ */
236
+ declare function withFaasData<TComponent extends React.FC<any>, PathOrData extends FaasAction>(Component: TComponent, faasProps: FaasDataWrapperProps<PathOrData>): (props: Omit<ComponentProps<TComponent>, "data">) => react_jsx_runtime.JSX.Element;
237
+
238
+ type OptionalWrapperProps<TWrapper extends ComponentType<{
239
+ children: ReactNode;
240
+ }> = any> = {
241
+ condition: boolean;
242
+ Wrapper: TWrapper;
243
+ wrapperProps?: ComponentProps<TWrapper>;
244
+ children: ReactNode;
245
+ };
246
+ /**
247
+ * A wrapper component that conditionally wraps its children with a provided wrapper component.
248
+ *
249
+ * @example
250
+ * ```tsx
251
+ * import { OptionalWrapper } from '@faasjs/react'
252
+ *
253
+ * const Wrapper = ({ children }: { children: React.ReactNode }) => (
254
+ * <div className='wrapper'>{children}</div>
255
+ * )
256
+ *
257
+ * const App = () => (
258
+ * <OptionalWrapper condition={true} Wrapper={Wrapper}>
259
+ * <span>Test</span>
260
+ * </OptionalWrapper>
261
+ * )
262
+ * ```
263
+ */
264
+ declare const OptionalWrapper: React.FC<OptionalWrapperProps> & {
265
+ whyDidYouRender: boolean;
266
+ };
267
+
268
+ export { ErrorBoundary, type ErrorBoundaryProps, type ErrorChildrenProps, type FaasDataInjection, FaasDataWrapper, type FaasDataWrapperProps, FaasReactClient, type FaasReactClientInstance, type FaasReactClientOptions, OptionalWrapper, type OptionalWrapperProps, createSplitedContext, createSplittingContext, faas, getClient, useConstant, useFaas, type useFaasOptions, withFaasData };
package/dist/index.js CHANGED
@@ -44,6 +44,48 @@ function createSplittingContext(defaultValue) {
44
44
  };
45
45
  }
46
46
  var createSplitedContext = createSplittingContext;
47
+ function FaasDataWrapper({
48
+ action,
49
+ params,
50
+ fallback,
51
+ render,
52
+ children,
53
+ onDataChange,
54
+ data,
55
+ setData,
56
+ domain
57
+ }) {
58
+ const request = getClient(domain).useFaas(action, params, {
59
+ data,
60
+ setData
61
+ });
62
+ const [loaded, setLoaded] = react.useState(false);
63
+ react.useEffect(() => {
64
+ if (!loaded && !request.loading) setLoaded(true);
65
+ }, [request.loading]);
66
+ react.useEffect(() => {
67
+ if (onDataChange) onDataChange(request);
68
+ }, [JSON.stringify(request.data)]);
69
+ const child = react.useMemo(() => {
70
+ if (loaded) {
71
+ if (children) return react.cloneElement(children, request);
72
+ if (render) return render(request);
73
+ }
74
+ return fallback || null;
75
+ }, [
76
+ loaded,
77
+ request.action,
78
+ request.params,
79
+ request.data,
80
+ request.error,
81
+ request.loading
82
+ ]);
83
+ return child;
84
+ }
85
+ FaasDataWrapper.whyDidYouRender = true;
86
+ function withFaasData(Component2, faasProps) {
87
+ return (props) => /* @__PURE__ */ jsxRuntime.jsx(FaasDataWrapper, { ...faasProps, children: /* @__PURE__ */ jsxRuntime.jsx(Component2, { ...props }) });
88
+ }
47
89
  var clients = {};
48
90
  function FaasReactClient({
49
91
  domain,
@@ -157,49 +199,11 @@ function FaasReactClient({
157
199
  };
158
200
  }
159
201
  useFaas2.whyDidYouRender = true;
160
- function FaasDataWrapper2({
161
- action,
162
- params,
163
- fallback,
164
- render,
165
- children,
166
- onDataChange,
167
- data,
168
- setData
169
- }) {
170
- const request = useFaas2(action, params, {
171
- data,
172
- setData
173
- });
174
- const [loaded, setLoaded] = react.useState(false);
175
- react.useEffect(() => {
176
- if (!loaded && !request.loading) setLoaded(true);
177
- }, [request.loading]);
178
- react.useEffect(() => {
179
- if (onDataChange) onDataChange(request);
180
- }, [JSON.stringify(request.data)]);
181
- const child = react.useMemo(() => {
182
- if (loaded) {
183
- if (children) return react.cloneElement(children, request);
184
- if (render) return render(request);
185
- }
186
- return fallback || null;
187
- }, [
188
- loaded,
189
- request.action,
190
- request.params,
191
- request.data,
192
- request.error,
193
- request.loading
194
- ]);
195
- return child;
196
- }
197
- FaasDataWrapper2.whyDidYouRender = true;
198
202
  const reactClient = {
199
203
  id: client.id,
200
204
  faas: faas2,
201
205
  useFaas: useFaas2,
202
- FaasDataWrapper: FaasDataWrapper2
206
+ FaasDataWrapper: (props) => /* @__PURE__ */ jsxRuntime.jsx(FaasDataWrapper, { domain, ...props })
203
207
  };
204
208
  clients[domain] = reactClient;
205
209
  return reactClient;
@@ -220,16 +224,6 @@ async function faas(action, params) {
220
224
  function useFaas(action, defaultParams, options) {
221
225
  return getClient().useFaas(action, defaultParams, options);
222
226
  }
223
- function FaasDataWrapper(props) {
224
- const [client, setClient] = react.useState();
225
- react.useEffect(() => {
226
- if (client) return;
227
- setClient(getClient());
228
- }, []);
229
- if (!client) return props.fallback || null;
230
- return /* @__PURE__ */ jsxRuntime.jsx(client.FaasDataWrapper, { ...props });
231
- }
232
- FaasDataWrapper.whyDidYouRender = true;
233
227
  var ErrorBoundary = class extends react.Component {
234
228
  constructor(props) {
235
229
  super(props);
@@ -268,13 +262,20 @@ var ErrorBoundary = class extends react.Component {
268
262
  };
269
263
  ErrorBoundary.whyDidYouRender = true;
270
264
  ErrorBoundary.whyDidYouRender = true;
265
+ var OptionalWrapper = ({ condition, Wrapper, wrapperProps, children }) => {
266
+ console.debug("[OptionalWrapper] %s %s", Wrapper.name, condition);
267
+ return condition ? /* @__PURE__ */ jsxRuntime.jsx(Wrapper, { ...wrapperProps, children }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
268
+ };
269
+ OptionalWrapper.whyDidYouRender = true;
271
270
 
272
271
  exports.ErrorBoundary = ErrorBoundary;
273
272
  exports.FaasDataWrapper = FaasDataWrapper;
274
273
  exports.FaasReactClient = FaasReactClient;
274
+ exports.OptionalWrapper = OptionalWrapper;
275
275
  exports.createSplitedContext = createSplitedContext;
276
276
  exports.createSplittingContext = createSplittingContext;
277
277
  exports.faas = faas;
278
278
  exports.getClient = getClient;
279
279
  exports.useConstant = useConstant;
280
280
  exports.useFaas = useFaas;
281
+ exports.withFaasData = withFaasData;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { useRef, createContext, useState, useEffect, Component, cloneElement, useContext, useCallback, useMemo } from 'react';
2
- import { jsx, jsxs } from 'react/jsx-runtime';
1
+ import { useRef, createContext, useState, useEffect, useMemo, cloneElement, Component, useContext, useCallback } from 'react';
2
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import { FaasBrowserClient } from '@faasjs/browser';
4
4
 
5
5
  // src/constant.ts
@@ -42,6 +42,48 @@ function createSplittingContext(defaultValue) {
42
42
  };
43
43
  }
44
44
  var createSplitedContext = createSplittingContext;
45
+ function FaasDataWrapper({
46
+ action,
47
+ params,
48
+ fallback,
49
+ render,
50
+ children,
51
+ onDataChange,
52
+ data,
53
+ setData,
54
+ domain
55
+ }) {
56
+ const request = getClient(domain).useFaas(action, params, {
57
+ data,
58
+ setData
59
+ });
60
+ const [loaded, setLoaded] = useState(false);
61
+ useEffect(() => {
62
+ if (!loaded && !request.loading) setLoaded(true);
63
+ }, [request.loading]);
64
+ useEffect(() => {
65
+ if (onDataChange) onDataChange(request);
66
+ }, [JSON.stringify(request.data)]);
67
+ const child = useMemo(() => {
68
+ if (loaded) {
69
+ if (children) return cloneElement(children, request);
70
+ if (render) return render(request);
71
+ }
72
+ return fallback || null;
73
+ }, [
74
+ loaded,
75
+ request.action,
76
+ request.params,
77
+ request.data,
78
+ request.error,
79
+ request.loading
80
+ ]);
81
+ return child;
82
+ }
83
+ FaasDataWrapper.whyDidYouRender = true;
84
+ function withFaasData(Component2, faasProps) {
85
+ return (props) => /* @__PURE__ */ jsx(FaasDataWrapper, { ...faasProps, children: /* @__PURE__ */ jsx(Component2, { ...props }) });
86
+ }
45
87
  var clients = {};
46
88
  function FaasReactClient({
47
89
  domain,
@@ -155,49 +197,11 @@ function FaasReactClient({
155
197
  };
156
198
  }
157
199
  useFaas2.whyDidYouRender = true;
158
- function FaasDataWrapper2({
159
- action,
160
- params,
161
- fallback,
162
- render,
163
- children,
164
- onDataChange,
165
- data,
166
- setData
167
- }) {
168
- const request = useFaas2(action, params, {
169
- data,
170
- setData
171
- });
172
- const [loaded, setLoaded] = useState(false);
173
- useEffect(() => {
174
- if (!loaded && !request.loading) setLoaded(true);
175
- }, [request.loading]);
176
- useEffect(() => {
177
- if (onDataChange) onDataChange(request);
178
- }, [JSON.stringify(request.data)]);
179
- const child = useMemo(() => {
180
- if (loaded) {
181
- if (children) return cloneElement(children, request);
182
- if (render) return render(request);
183
- }
184
- return fallback || null;
185
- }, [
186
- loaded,
187
- request.action,
188
- request.params,
189
- request.data,
190
- request.error,
191
- request.loading
192
- ]);
193
- return child;
194
- }
195
- FaasDataWrapper2.whyDidYouRender = true;
196
200
  const reactClient = {
197
201
  id: client.id,
198
202
  faas: faas2,
199
203
  useFaas: useFaas2,
200
- FaasDataWrapper: FaasDataWrapper2
204
+ FaasDataWrapper: (props) => /* @__PURE__ */ jsx(FaasDataWrapper, { domain, ...props })
201
205
  };
202
206
  clients[domain] = reactClient;
203
207
  return reactClient;
@@ -218,16 +222,6 @@ async function faas(action, params) {
218
222
  function useFaas(action, defaultParams, options) {
219
223
  return getClient().useFaas(action, defaultParams, options);
220
224
  }
221
- function FaasDataWrapper(props) {
222
- const [client, setClient] = useState();
223
- useEffect(() => {
224
- if (client) return;
225
- setClient(getClient());
226
- }, []);
227
- if (!client) return props.fallback || null;
228
- return /* @__PURE__ */ jsx(client.FaasDataWrapper, { ...props });
229
- }
230
- FaasDataWrapper.whyDidYouRender = true;
231
225
  var ErrorBoundary = class extends Component {
232
226
  constructor(props) {
233
227
  super(props);
@@ -266,5 +260,10 @@ var ErrorBoundary = class extends Component {
266
260
  };
267
261
  ErrorBoundary.whyDidYouRender = true;
268
262
  ErrorBoundary.whyDidYouRender = true;
263
+ var OptionalWrapper = ({ condition, Wrapper, wrapperProps, children }) => {
264
+ console.debug("[OptionalWrapper] %s %s", Wrapper.name, condition);
265
+ return condition ? /* @__PURE__ */ jsx(Wrapper, { ...wrapperProps, children }) : /* @__PURE__ */ jsx(Fragment, { children });
266
+ };
267
+ OptionalWrapper.whyDidYouRender = true;
269
268
 
270
- export { ErrorBoundary, FaasDataWrapper, FaasReactClient, createSplitedContext, createSplittingContext, faas, getClient, useConstant, useFaas };
269
+ export { ErrorBoundary, FaasDataWrapper, FaasReactClient, OptionalWrapper, createSplitedContext, createSplittingContext, faas, getClient, useConstant, useFaas, withFaasData };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/react",
3
- "version": "2.6.1",
3
+ "version": "2.8.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -17,7 +17,7 @@
17
17
  }
18
18
  }
19
19
  },
20
- "homepage": "https://faasjs.com/doc/react",
20
+ "homepage": "https://faasjs.com/doc/react/",
21
21
  "repository": {
22
22
  "type": "git",
23
23
  "url": "git+https://github.com/faasjs/faasjs.git",
@@ -34,7 +34,7 @@
34
34
  "dist"
35
35
  ],
36
36
  "dependencies": {
37
- "@faasjs/browser": "2.6.1"
37
+ "@faasjs/browser": "2.8.0"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "react": "*"