@umituz/react-native-subscription 3.1.20 → 3.1.21
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": "3.1.
|
|
3
|
+
"version": "3.1.21",
|
|
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",
|
|
@@ -88,19 +88,23 @@ export const PaywallScreen: React.FC<PaywallScreenProps> = React.memo((props) =>
|
|
|
88
88
|
onClose: handleClose
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
+
// Cleanup on unmount only - resetState is stable from useCallback
|
|
91
92
|
useEffect(() => {
|
|
92
93
|
return () => {
|
|
93
94
|
if (__DEV__) console.log('[PaywallScreen] 🧹 Cleanup: resetting state');
|
|
94
95
|
resetState();
|
|
95
96
|
};
|
|
96
|
-
|
|
97
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
98
|
+
}, []);
|
|
97
99
|
|
|
98
100
|
// Auto-select first package
|
|
99
101
|
useEffect(() => {
|
|
100
102
|
if (hasItems(packages) && !selectedPlanId) {
|
|
101
103
|
setSelectedPlanId(packages[0].product.identifier);
|
|
102
104
|
}
|
|
103
|
-
|
|
105
|
+
// setSelectedPlanId is stable from useState, packages.length is sufficient
|
|
106
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
107
|
+
}, [packages?.length, selectedPlanId]);
|
|
104
108
|
|
|
105
109
|
const handleLegalUrl = useCallback(async (url: string | undefined) => {
|
|
106
110
|
if (!url) return;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Handlers extracted to separate modules for better maintainability.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { useState, useRef, useMemo } from "react";
|
|
8
|
+
import { useState, useRef, useMemo, useCallback } from "react";
|
|
9
9
|
import type { UsePaywallActionsParams } from "./usePaywallActions.types";
|
|
10
10
|
import { usePurchaseHandler } from "./usePaywallPurchase";
|
|
11
11
|
import { useRestoreHandler } from "./usePaywallRestore";
|
|
@@ -59,14 +59,14 @@ export function usePaywallActions({
|
|
|
59
59
|
callbacksRef,
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
// Reset state
|
|
63
|
-
const resetState = () => {
|
|
62
|
+
// Reset state - memoized with useCallback to prevent infinite loops
|
|
63
|
+
const resetState = useCallback(() => {
|
|
64
64
|
if (__DEV__) {
|
|
65
65
|
console.log('[usePaywallActions] 🧹 Resetting state');
|
|
66
66
|
}
|
|
67
67
|
setSelectedPlanId(null);
|
|
68
68
|
setIsProcessing(false);
|
|
69
|
-
};
|
|
69
|
+
}, []);
|
|
70
70
|
|
|
71
71
|
// Return API
|
|
72
72
|
return useMemo(() => ({
|
|
@@ -76,5 +76,5 @@ export function usePaywallActions({
|
|
|
76
76
|
handlePurchase,
|
|
77
77
|
handleRestore,
|
|
78
78
|
resetState,
|
|
79
|
-
}), [selectedPlanId, isProcessing, handlePurchase, handleRestore]);
|
|
79
|
+
}), [selectedPlanId, isProcessing, handlePurchase, handleRestore, resetState]);
|
|
80
80
|
}
|