@umituz/react-native-subscription 2.40.5 → 2.40.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-subscription",
3
- "version": "2.40.5",
3
+ "version": "2.40.6",
4
4
  "description": "Complete subscription management with RevenueCat, paywall UI, and credits system for React Native apps",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -1,4 +1,4 @@
1
- import { useCallback } from 'react';
1
+ import { useCallback, useMemo } from 'react';
2
2
  import type { PurchasesPackage } from 'react-native-purchases';
3
3
  import { useCredits } from '../../credits/presentation/useCredits';
4
4
  import { useSubscriptionStatus } from './useSubscriptionStatus';
@@ -11,12 +11,14 @@ import { usePaywallVisibility } from './usePaywallVisibility';
11
11
  import { isPremiumSyncPending } from '../utils/syncStatus';
12
12
  import { UsePremiumResult } from './usePremium.types';
13
13
 
14
+ const EMPTY_PACKAGES: PurchasesPackage[] = [];
15
+
14
16
  export const usePremium = (): UsePremiumResult => {
15
17
 
16
18
  const { isPremium: subscriptionActive, isLoading: statusLoading } = useSubscriptionStatus();
17
19
  const { credits, isLoading: creditsLoading } = useCredits();
18
20
 
19
- const { data: packages = [], isLoading: packagesLoading } = useSubscriptionPackages();
21
+ const { data: packages = EMPTY_PACKAGES, isLoading: packagesLoading } = useSubscriptionPackages();
20
22
 
21
23
  const purchaseMutation = usePurchasePackage();
22
24
  const restoreMutation = useRestorePurchase();
@@ -52,7 +54,7 @@ export const usePremium = (): UsePremiumResult => {
52
54
  }
53
55
  }, [restoreMutation]);
54
56
 
55
- return {
57
+ return useMemo(() => ({
56
58
  isPremium,
57
59
  isLoading:
58
60
  statusLoading ||
@@ -69,5 +71,21 @@ export const usePremium = (): UsePremiumResult => {
69
71
  setShowPaywall,
70
72
  closePaywall,
71
73
  openPaywall,
72
- };
74
+ }), [
75
+ isPremium,
76
+ statusLoading,
77
+ creditsLoading,
78
+ packagesLoading,
79
+ purchaseMutation.isPending,
80
+ restoreMutation.isPending,
81
+ packages,
82
+ credits,
83
+ showPaywall,
84
+ isSyncing,
85
+ handlePurchase,
86
+ handleRestore,
87
+ setShowPaywall,
88
+ closePaywall,
89
+ openPaywall,
90
+ ]);
73
91
  };