@umituz/react-native-subscription 2.14.40 → 2.14.41
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.14.
|
|
3
|
+
"version": "2.14.41",
|
|
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",
|
|
@@ -21,17 +21,22 @@ export const creditsQueryKeys = {
|
|
|
21
21
|
user: (userId: string) => ["credits", userId] as const,
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
+
/** Default stale time: 30 seconds - prevents infinite re-render loops */
|
|
25
|
+
const DEFAULT_STALE_TIME = 30 * 1000;
|
|
26
|
+
/** Default gc time: 5 minutes */
|
|
27
|
+
const DEFAULT_GC_TIME = 5 * 60 * 1000;
|
|
28
|
+
|
|
24
29
|
export interface CreditsCacheConfig {
|
|
25
|
-
/** Time in ms before data is considered stale. Default:
|
|
30
|
+
/** Time in ms before data is considered stale. Default: 30 seconds */
|
|
26
31
|
staleTime?: number;
|
|
27
|
-
/** Time in ms before inactive data is garbage collected. Default:
|
|
32
|
+
/** Time in ms before inactive data is garbage collected. Default: 5 minutes */
|
|
28
33
|
gcTime?: number;
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
export interface UseCreditsParams {
|
|
32
37
|
userId: string | undefined;
|
|
33
38
|
enabled?: boolean;
|
|
34
|
-
/** Cache configuration. Default:
|
|
39
|
+
/** Cache configuration. Default: 30 second staleTime, 5 minute gcTime */
|
|
35
40
|
cache?: CreditsCacheConfig;
|
|
36
41
|
}
|
|
37
42
|
|
|
@@ -56,9 +61,9 @@ export const useCredits = ({
|
|
|
56
61
|
const isConfigured = isCreditsRepositoryConfigured();
|
|
57
62
|
const config = getCreditsConfig();
|
|
58
63
|
|
|
59
|
-
// Default:
|
|
60
|
-
const staleTime = cache?.staleTime ??
|
|
61
|
-
const gcTime = cache?.gcTime ??
|
|
64
|
+
// Default: 30 second stale time to prevent infinite re-render loops
|
|
65
|
+
const staleTime = cache?.staleTime ?? DEFAULT_STALE_TIME;
|
|
66
|
+
const gcTime = cache?.gcTime ?? DEFAULT_GC_TIME;
|
|
62
67
|
|
|
63
68
|
const { data, isLoading, error, refetch } = useQuery({
|
|
64
69
|
queryKey: creditsQueryKeys.user(userId ?? ""),
|
|
@@ -95,6 +95,6 @@ export const useSubscriptionPackages = (userId: string | undefined) => {
|
|
|
95
95
|
staleTime: STALE_TIME,
|
|
96
96
|
gcTime: GC_TIME,
|
|
97
97
|
enabled: isConfigured, // Only enabled when SubscriptionManager is configured
|
|
98
|
-
refetchOnMount:
|
|
98
|
+
refetchOnMount: true, // Respects staleTime - refetches only if data is stale
|
|
99
99
|
});
|
|
100
100
|
};
|