@faasjs/react 8.0.0-beta.31 → 8.0.0-beta.33

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 CHANGED
@@ -228,7 +228,7 @@ type FaasDataInjection<Path extends FaasActionPaths> = {
228
228
  * When the source hook is currently skipped, calling `reload` clears the skip
229
229
  * flag before starting the next request.
230
230
  */
231
- reload(params?: FaasParams<Path>, options?: {
231
+ reload(this: void, params?: FaasParams<Path>, options?: {
232
232
  silent?: boolean;
233
233
  }): Promise<FaasData<Path>>; /** Controlled or internal setter for the resolved data value. */
234
234
  setData: React.Dispatch<React.SetStateAction<FaasData<Path>>>; /** Setter for the loading flag. */
@@ -656,7 +656,7 @@ declare class ErrorBoundary extends Component<ErrorBoundaryProps, {
656
656
  /**
657
657
  * Render children or the configured fallback for the captured error.
658
658
  */
659
- render(): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | _$react.ReactPortal | ReactElement<unknown, string | _$react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | _$react_jsx_runtime0.JSX.Element | null;
659
+ render(): string | number | bigint | boolean | _$react_jsx_runtime0.JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | _$react.ReactPortal | ReactElement<unknown, string | _$react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null;
660
660
  }
661
661
  //#endregion
662
662
  //#region src/equal/index.d.ts
@@ -803,7 +803,7 @@ type OptionalWrapperProps<TWrapper extends ComponentType<{
803
803
  * )
804
804
  * ```
805
805
  */
806
- declare function OptionalWrapper(props: OptionalWrapperProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | _$react.ReactPortal | _$react.ReactElement<unknown, string | _$react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | _$react_jsx_runtime0.JSX.Element | null | undefined;
806
+ declare function OptionalWrapper(props: OptionalWrapperProps): string | number | bigint | boolean | _$react_jsx_runtime0.JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | _$react.ReactPortal | _$react.ReactElement<unknown, string | _$react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
807
807
  declare namespace OptionalWrapper {
808
808
  var displayName: string;
809
809
  }
@@ -1045,8 +1045,8 @@ declare function usePrevious<T = any>(value: T): T | undefined;
1045
1045
  * Custom hook that returns a stateful value and a ref to that value.
1046
1046
  *
1047
1047
  * @template T - The type of the value.
1048
- * @param {T} [initialValue] - Initial state value. When omitted, state starts as `null`.
1049
- * @returns {[T | null, Dispatch<SetStateAction<T | null>>, RefObject<T | null>]} Tuple containing the current state, the state setter, and a ref that always points at the latest state.
1048
+ * @param {T} [initialValue] - Initial state value. Defaults to `undefined`.
1049
+ * @returns {[T, Dispatch<SetStateAction<T>>, RefObject<T>]} Tuple containing the current state, the state setter, and a ref that always points at the latest state.
1050
1050
  *
1051
1051
  * @example
1052
1052
  * ```tsx
@@ -1065,6 +1065,7 @@ declare function usePrevious<T = any>(value: T): T | undefined;
1065
1065
  * }
1066
1066
  * ```
1067
1067
  */
1068
- declare function useStateRef<T = any>(initialValue?: T): [T | null, Dispatch<SetStateAction<T | null>>, RefObject<T | null>];
1068
+ declare function useStateRef<T>(initialValue: T | (() => T)): [T, Dispatch<SetStateAction<T>>, RefObject<T>];
1069
+ declare function useStateRef<T = undefined>(): [T | undefined, Dispatch<SetStateAction<T | undefined>>, RefObject<T | undefined>];
1069
1070
  //#endregion
1070
1071
  export { type BaseUrl, ErrorBoundary, ErrorBoundaryProps, ErrorChildrenProps, FaasBrowserClient, type FaasBrowserClientAction, FaasDataInjection, FaasDataWrapper, FaasDataWrapperProps, FaasDataWrapperRef, FaasReactClient, FaasReactClientInstance, FaasReactClientOptions, type MockHandler, OnError, OptionalWrapper, OptionalWrapperProps, type Options, Response, ResponseError, type ResponseErrorProps, type ResponseHeaders, type ResponseProps, StateSetters, StatesWithSetters, UseFaasOptions, UseFaasStreamOptions, UseFaasStreamResult, createSplittingContext, equal, faas, generateId, getClient, setMock, useConstant, useEqualCallback, useEqualEffect, useEqualMemo, useEqualMemoize, useFaas, useFaasStream, usePrevious, useSplittingState, useStateRef, withFaasData };
package/dist/index.mjs CHANGED
@@ -144,7 +144,7 @@ async function resolveMockResponse(action, params, options) {
144
144
  //#endregion
145
145
  //#region src/browser/helpers.ts
146
146
  function buildActionUrl(action, baseUrl, options, requestId) {
147
- return `${(options?.baseUrl || baseUrl) + action.toLowerCase()}?_=${requestId}`;
147
+ return `${(options?.baseUrl || baseUrl) + action}?_=${requestId}`;
148
148
  }
149
149
  function buildActionOptions(defaultOptions, options, params, requestId) {
150
150
  const resolvedOptions = {
@@ -1387,32 +1387,8 @@ function usePrevious(value) {
1387
1387
  }
1388
1388
  //#endregion
1389
1389
  //#region src/useStateRef/index.ts
1390
- /**
1391
- * Custom hook that returns a stateful value and a ref to that value.
1392
- *
1393
- * @template T - The type of the value.
1394
- * @param {T} [initialValue] - Initial state value. When omitted, state starts as `null`.
1395
- * @returns {[T | null, Dispatch<SetStateAction<T | null>>, RefObject<T | null>]} Tuple containing the current state, the state setter, and a ref that always points at the latest state.
1396
- *
1397
- * @example
1398
- * ```tsx
1399
- * import { useStateRef } from '@faasjs/react'
1400
- *
1401
- * function MyComponent() {
1402
- * const [value, setValue, ref] = useStateRef(0)
1403
- *
1404
- * return (
1405
- * <div>
1406
- * <p>Value: {value}</p>
1407
- * <button onClick={() => setValue(value + 1)}>Increment</button>
1408
- * <button onClick={() => console.log(ref.current)}>Submit</button>
1409
- * </div>
1410
- * )
1411
- * }
1412
- * ```
1413
- */
1414
1390
  function useStateRef(initialValue) {
1415
- const [state, setState] = useState(initialValue ?? null);
1391
+ const [state, setState] = useState(initialValue);
1416
1392
  const ref = useRef(state);
1417
1393
  useEffect(() => {
1418
1394
  ref.current = state;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/react",
3
- "version": "8.0.0-beta.31",
3
+ "version": "8.0.0-beta.33",
4
4
  "homepage": "https://faasjs.com/doc/react/",
5
5
  "bugs": {
6
6
  "url": "https://github.com/faasjs/faasjs/issues"
@@ -26,12 +26,12 @@
26
26
  }
27
27
  },
28
28
  "devDependencies": {
29
- "@faasjs/types": ">=8.0.0-beta.31",
29
+ "@faasjs/types": ">=8.0.0-beta.33",
30
30
  "@types/react": "^19.0.0",
31
31
  "react": "^19.0.0"
32
32
  },
33
33
  "peerDependencies": {
34
- "@faasjs/types": ">=8.0.0-beta.31"
34
+ "@faasjs/types": ">=8.0.0-beta.33"
35
35
  },
36
36
  "engines": {
37
37
  "node": ">=26.0.0",