@umituz/react-native-auth 1.10.0 → 1.11.0

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": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "description": "Authentication service for React Native apps - Secure, type-safe, and production-ready. Provider-agnostic design supports Firebase Auth and can be adapted for Supabase or other providers.",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -3,7 +3,7 @@
3
3
  * Single Responsibility: Manage authentication state
4
4
  */
5
5
 
6
- import { useState, useEffect, useRef } from "react";
6
+ import { useState, useEffect, useRef, useMemo } from "react";
7
7
  import { DeviceEventEmitter } from "react-native";
8
8
  import { getAuthService } from "../../infrastructure/services/AuthService";
9
9
  import { useFirebaseAuth } from "@umituz/react-native-firebase-auth";
@@ -36,7 +36,12 @@ export function useAuthState(): UseAuthStateResult {
36
36
  // Ref to track latest isGuest value for event handlers
37
37
  const isGuestRef = useRef(isGuest);
38
38
 
39
- const user = isGuest ? null : mapToAuthUser(firebaseUser);
39
+ // Memoize user to prevent new object reference on every render
40
+ const user = useMemo(() => {
41
+ if (isGuest) return null;
42
+ return mapToAuthUser(firebaseUser);
43
+ }, [isGuest, firebaseUser?.uid]);
44
+
40
45
  const isAuthenticated = !!user && !isGuest;
41
46
 
42
47
  // Keep ref in sync with state