@nozle-js/react 0.10.0 → 0.10.1
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 +5 -1
- package/dist/index.cjs +11 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -2866,8 +2866,12 @@ function usePlans() {
|
|
|
2866
2866
|
const { client } = useBillingContext();
|
|
2867
2867
|
const [plans, setPlans] = useState([]);
|
|
2868
2868
|
const [isLoading, setIsLoading] = useState(true);
|
|
2869
|
+
const [error, setError] = useState(null);
|
|
2869
2870
|
useEffect(() => {
|
|
2870
2871
|
let cancelled = false;
|
|
2872
|
+
setIsLoading(true);
|
|
2873
|
+
setError(null);
|
|
2874
|
+
setPlans([]);
|
|
2871
2875
|
if (!client) {
|
|
2872
2876
|
setIsLoading(false);
|
|
2873
2877
|
return;
|
|
@@ -2876,6 +2880,12 @@ function usePlans() {
|
|
|
2876
2880
|
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
2877
2881
|
const data = await response.json();
|
|
2878
2882
|
if (!cancelled) setPlans(data.plans ?? []);
|
|
2883
|
+
}).catch((cause) => {
|
|
2884
|
+
if (!cancelled) {
|
|
2885
|
+
setError(
|
|
2886
|
+
cause instanceof Error ? cause : new Error("Failed to load plans")
|
|
2887
|
+
);
|
|
2888
|
+
}
|
|
2879
2889
|
}).finally(() => {
|
|
2880
2890
|
if (!cancelled) setIsLoading(false);
|
|
2881
2891
|
});
|
|
@@ -2883,7 +2893,7 @@ function usePlans() {
|
|
|
2883
2893
|
cancelled = true;
|
|
2884
2894
|
};
|
|
2885
2895
|
}, [client]);
|
|
2886
|
-
return { plans, isLoading };
|
|
2896
|
+
return { plans, isLoading, error };
|
|
2887
2897
|
}
|
|
2888
2898
|
function useCheckout2() {
|
|
2889
2899
|
const { createCheckout } = useBillingContext();
|