@dynamic-labs-sdk/react-hooks 1.8.1 → 1.8.2

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.esm.js CHANGED
@@ -7,7 +7,7 @@ import { getCore } from "@dynamic-labs-sdk/client/core";
7
7
 
8
8
  //#region package.json
9
9
  var name = "@dynamic-labs-sdk/react-hooks";
10
- var version = "1.8.1";
10
+ var version = "1.8.2";
11
11
 
12
12
  //#endregion
13
13
  //#region src/modules/DynamicContext/DynamicContext.ts
@@ -755,17 +755,45 @@ const useGoogleDriveBackupReadiness = ({ queryParams } = {}) => useBaseQuery({
755
755
  //#endregion
756
756
  //#region src/hooks/useInitStatus/useInitStatus.ts
757
757
  /**
758
- * Returns the current initialization status of the Dynamic client.
758
+ * Returns the current initialization status of the Dynamic client, plus the
759
+ * error that caused initialization to fail (when it did).
759
760
  *
760
- * Possible values: 'uninitialized', 'in-progress', 'finished', 'failed'.
761
+ * Exposes only `data` (the reactive init status), `error` and `isError` —
762
+ * see {@link UseInitStatusResult}. Possible `data` values: `'uninitialized'`,
763
+ * `'in-progress'`, `'finished'`, `'failed'`. When `data === 'failed'`, `error`
764
+ * carries the failure reason.
765
+ *
766
+ * @example
767
+ * ```tsx
768
+ * const { data: status, error } = useInitStatus();
769
+ * if (status === 'failed') return <InitErrorScreen message={error?.message} />;
770
+ * if (status !== 'finished') return <LoadingScreen />;
771
+ * return <App />;
772
+ * ```
773
+ *
774
+ * @not-instrumented
761
775
  */
762
- const useInitStatus = () => useBaseState({
763
- defaultValue: "uninitialized",
764
- event: "initStatusChanged",
765
- queryKey: ["useInitStatus"],
766
- selector: (client) => client.initStatus,
767
- skipWaitForInit: true
768
- });
776
+ const useInitStatus = () => {
777
+ const { data } = useBaseState({
778
+ defaultValue: {
779
+ error: null,
780
+ status: "uninitialized"
781
+ },
782
+ event: "initStatusChanged",
783
+ queryKey: ["useInitStatus"],
784
+ selector: (client) => ({
785
+ error: client.initError,
786
+ status: client.initStatus
787
+ }),
788
+ skipWaitForInit: true
789
+ });
790
+ const error = data?.error ?? null;
791
+ return {
792
+ data: data?.status,
793
+ error,
794
+ isError: error !== null
795
+ };
796
+ };
769
797
 
770
798
  //#endregion
771
799
  //#region src/hooks/useIsCaptchaRequired/useIsCaptchaRequired.ts