@umituz/react-native-auth 4.3.42 → 4.3.44
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-auth",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.44",
|
|
4
4
|
"description": "Authentication service for React Native apps - Secure, type-safe, and production-ready. Provider-agnostic design with dependency injection, configurable validation, and comprehensive error handling.",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -18,7 +18,7 @@ export function useRegisterFormHandlers(
|
|
|
18
18
|
clearFieldError(setFieldErrors, "displayName");
|
|
19
19
|
clearLocalError();
|
|
20
20
|
},
|
|
21
|
-
[updateField, clearLocalError]
|
|
21
|
+
[updateField, clearLocalError, setFieldErrors]
|
|
22
22
|
);
|
|
23
23
|
|
|
24
24
|
const handleEmailChange = useCallback(
|
|
@@ -27,7 +27,7 @@ export function useRegisterFormHandlers(
|
|
|
27
27
|
clearFieldError(setFieldErrors, "email");
|
|
28
28
|
clearLocalError();
|
|
29
29
|
},
|
|
30
|
-
[updateField, clearLocalError]
|
|
30
|
+
[updateField, clearLocalError, setFieldErrors]
|
|
31
31
|
);
|
|
32
32
|
|
|
33
33
|
const handlePasswordChange = useCallback(
|
|
@@ -36,7 +36,7 @@ export function useRegisterFormHandlers(
|
|
|
36
36
|
clearFieldErrors(setFieldErrors, ["password", "confirmPassword"]);
|
|
37
37
|
clearLocalError();
|
|
38
38
|
},
|
|
39
|
-
[updateField, clearLocalError]
|
|
39
|
+
[updateField, clearLocalError, setFieldErrors]
|
|
40
40
|
);
|
|
41
41
|
|
|
42
42
|
const handleConfirmPasswordChange = useCallback(
|
|
@@ -45,7 +45,7 @@ export function useRegisterFormHandlers(
|
|
|
45
45
|
clearFieldError(setFieldErrors, "confirmPassword");
|
|
46
46
|
clearLocalError();
|
|
47
47
|
},
|
|
48
|
-
[updateField, clearLocalError]
|
|
48
|
+
[updateField, clearLocalError, setFieldErrors]
|
|
49
49
|
);
|
|
50
50
|
|
|
51
51
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useState } from "react";
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
2
|
import { useAppDesignTokens } from "@umituz/react-native-design-system/theme";
|
|
3
3
|
import { StackNavigator, type StackNavigatorConfig, type StackScreenProps } from "@umituz/react-native-design-system/molecules";
|
|
4
4
|
import { storageRepository, unwrap } from "@umituz/react-native-design-system/storage";
|
|
@@ -52,15 +52,19 @@ export const AuthNavigator: React.FC<AuthNavigatorProps> = ({
|
|
|
52
52
|
void checkInitialRoute();
|
|
53
53
|
}, []);
|
|
54
54
|
|
|
55
|
+
// Memoize nested translation objects to prevent screen wrapper recreation
|
|
56
|
+
const loginTranslations = useMemo(() => translations.login, [translations.login]);
|
|
57
|
+
const registerTranslations = useMemo(() => translations.register, [translations.register]);
|
|
58
|
+
|
|
55
59
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
60
|
const LoginScreenWrapper = useCallback(
|
|
57
61
|
(props: any) => (
|
|
58
62
|
<LoginScreen
|
|
59
63
|
{...props}
|
|
60
|
-
translations={
|
|
64
|
+
translations={loginTranslations}
|
|
61
65
|
/>
|
|
62
66
|
),
|
|
63
|
-
[
|
|
67
|
+
[loginTranslations]
|
|
64
68
|
);
|
|
65
69
|
|
|
66
70
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -68,14 +72,14 @@ export const AuthNavigator: React.FC<AuthNavigatorProps> = ({
|
|
|
68
72
|
(props: any) => (
|
|
69
73
|
<RegisterScreen
|
|
70
74
|
{...props}
|
|
71
|
-
translations={
|
|
75
|
+
translations={registerTranslations}
|
|
72
76
|
termsUrl={termsUrl}
|
|
73
77
|
privacyUrl={privacyUrl}
|
|
74
78
|
onTermsPress={onTermsPress}
|
|
75
79
|
onPrivacyPress={onPrivacyPress}
|
|
76
80
|
/>
|
|
77
81
|
),
|
|
78
|
-
[
|
|
82
|
+
[registerTranslations, termsUrl, privacyUrl, onTermsPress, onPrivacyPress]
|
|
79
83
|
);
|
|
80
84
|
|
|
81
85
|
if (initialRouteName === undefined) {
|
|
@@ -28,6 +28,10 @@ export function useAuthTransitions(
|
|
|
28
28
|
const prevIsAnonymousRef = useRef(state.isAnonymous);
|
|
29
29
|
const prevIsVisibleRef = useRef(state.isVisible);
|
|
30
30
|
const cleanupRef = useRef<(() => void) | null>(null);
|
|
31
|
+
const onTransitionRef = useRef(onTransition);
|
|
32
|
+
|
|
33
|
+
// Keep ref in sync without adding to effect deps
|
|
34
|
+
onTransitionRef.current = onTransition;
|
|
31
35
|
|
|
32
36
|
useEffect(() => {
|
|
33
37
|
const justAuthenticated = !prevIsAuthenticatedRef.current && state.isAuthenticated;
|
|
@@ -45,7 +49,7 @@ export function useAuthTransitions(
|
|
|
45
49
|
// Call previous cleanup before running new transition
|
|
46
50
|
cleanupRef.current?.();
|
|
47
51
|
|
|
48
|
-
const cleanup =
|
|
52
|
+
const cleanup = onTransitionRef.current?.(result);
|
|
49
53
|
cleanupRef.current = (typeof cleanup === 'function' ? cleanup : null);
|
|
50
54
|
|
|
51
55
|
prevIsAuthenticatedRef.current = state.isAuthenticated;
|
|
@@ -57,7 +61,7 @@ export function useAuthTransitions(
|
|
|
57
61
|
cleanupRef.current?.();
|
|
58
62
|
cleanupRef.current = null;
|
|
59
63
|
};
|
|
60
|
-
}, [state.isAuthenticated, state.isVisible, state.isAnonymous
|
|
64
|
+
}, [state.isAuthenticated, state.isVisible, state.isAnonymous]);
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
/**
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Provides reusable form field state management with automatic error clearing
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { useCallback, useState } from "react";
|
|
6
|
+
import { useCallback, useRef, useState } from "react";
|
|
7
7
|
|
|
8
8
|
interface UseFormFieldOptions {
|
|
9
9
|
clearLocalError?: () => void;
|
|
@@ -24,18 +24,25 @@ export function useFormFields<T extends Record<string, string>>(
|
|
|
24
24
|
|
|
25
25
|
const [fields, setFields] = useState<T>(initialFields);
|
|
26
26
|
|
|
27
|
+
// Capture the initial fields only once so resetFields has a stable dep
|
|
28
|
+
const initialFieldsRef = useRef(initialFields);
|
|
29
|
+
|
|
30
|
+
// Use the function ref directly to avoid re-creating updateField when options object reference changes
|
|
31
|
+
const clearLocalErrorRef = useRef(options?.clearLocalError);
|
|
32
|
+
clearLocalErrorRef.current = options?.clearLocalError;
|
|
33
|
+
|
|
27
34
|
const updateField = useCallback(
|
|
28
35
|
(field: FieldKey, value: string) => {
|
|
29
36
|
setFields((prev) => ({ ...prev, [field]: value }));
|
|
30
37
|
// Note: setFieldErrors is handled externally by form hooks
|
|
31
|
-
|
|
38
|
+
clearLocalErrorRef.current?.();
|
|
32
39
|
},
|
|
33
|
-
[
|
|
40
|
+
[] // No deps - uses refs internally
|
|
34
41
|
);
|
|
35
42
|
|
|
36
43
|
const resetFields = useCallback(() => {
|
|
37
|
-
setFields(
|
|
38
|
-
}, [
|
|
44
|
+
setFields(initialFieldsRef.current);
|
|
45
|
+
}, []); // No deps - always resets to original initial values
|
|
39
46
|
|
|
40
47
|
return {
|
|
41
48
|
fields,
|