@umituz/react-native-splash 1.11.0 → 1.12.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-splash",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "Generic splash screen for React Native apps with animations, gradients, and customizable branding. SOLID, DRY, KISS principles applied.",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -5,7 +5,7 @@
5
5
  * Only basic React Native + expo-linear-gradient + safe-area
6
6
  */
7
7
 
8
- import React, { useEffect, useRef } from "react";
8
+ import React, { useEffect, useRef, useCallback } from "react";
9
9
  import { View, Text, StyleSheet, ActivityIndicator } from "react-native";
10
10
  import { LinearGradient } from "expo-linear-gradient";
11
11
  import { useSafeAreaInsets } from "react-native-safe-area-context";
@@ -36,23 +36,33 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({
36
36
  }) => {
37
37
  const insets = useSafeAreaInsets();
38
38
  const timerRef = useRef<NodeJS.Timeout | null>(null);
39
+ const onReadyRef = useRef(onReady);
40
+ const hasCalledOnReady = useRef(false);
39
41
 
40
- if (__DEV__) console.log("[SplashScreen] visible:", visible);
42
+ // Keep onReady ref updated but don't trigger re-render
43
+ useEffect(() => {
44
+ onReadyRef.current = onReady;
45
+ }, [onReady]);
46
+
47
+ // Stable callback that uses ref
48
+ const handleReady = useCallback(() => {
49
+ if (hasCalledOnReady.current) return;
50
+ hasCalledOnReady.current = true;
51
+ onReadyRef.current?.();
52
+ }, []);
41
53
 
42
54
  useEffect(() => {
43
55
  if (!visible) return;
44
56
 
45
- if (__DEV__) console.log("[SplashScreen] Timer start:", minimumDisplayTime);
57
+ // Reset when becoming visible again
58
+ hasCalledOnReady.current = false;
46
59
 
47
- timerRef.current = setTimeout(() => {
48
- if (__DEV__) console.log("[SplashScreen] onReady called");
49
- onReady?.();
50
- }, minimumDisplayTime);
60
+ timerRef.current = setTimeout(handleReady, minimumDisplayTime);
51
61
 
52
62
  return () => {
53
63
  if (timerRef.current) clearTimeout(timerRef.current);
54
64
  };
55
- }, [visible, minimumDisplayTime, onReady]);
65
+ }, [visible, minimumDisplayTime, handleReady]);
56
66
 
57
67
  if (!visible) return null;
58
68