1- import { useCallback , useRef } from 'react' ;
1+ import { useEffect , useEffectEvent , useRef } from 'react' ;
22import type { ViewStyle } from 'react-native' ;
33import { StyleSheet } from 'react-native' ;
44import Reanimated , { Easing , useAnimatedStyle , useSharedValue , withTiming } from 'react-native-reanimated' ;
@@ -9,7 +9,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
99import BootSplash from '@libs/BootSplash' ;
1010import type { SplashScreenHiderProps , SplashScreenHiderReturnType } from './types' ;
1111
12- function SplashScreenHider ( { onHide = ( ) => { } } : SplashScreenHiderProps ) : SplashScreenHiderReturnType {
12+ function SplashScreenHider ( { onHide, shouldHideSplash } : SplashScreenHiderProps ) : SplashScreenHiderReturnType {
1313 const styles = useThemeStyles ( ) ;
1414 const logoSizeRatio = BootSplash . logoSizeRatio || 1 ;
1515
@@ -24,8 +24,7 @@ function SplashScreenHider({onHide = () => {}}: SplashScreenHiderProps): SplashS
2424 } ) ) ;
2525
2626 const hideHasBeenCalled = useRef ( false ) ;
27-
28- const hide = useCallback ( ( ) => {
27+ const hide = useEffectEvent ( ( ) => {
2928 // hide can only be called once
3029 if ( hideHasBeenCalled . current ) {
3130 return ;
@@ -52,13 +51,19 @@ function SplashScreenHider({onHide = () => {}}: SplashScreenHiderProps): SplashS
5251 ) ,
5352 ) ;
5453 } ) ;
55- } , [ opacity , scale , onHide ] ) ;
54+ } ) ;
55+
56+ useEffect ( ( ) => {
57+ if ( ! shouldHideSplash ) {
58+ return ;
59+ }
60+ hide ( ) ;
61+ } , [ shouldHideSplash ] ) ;
5662
5763 return (
5864 < Reanimated . View style = { [ StyleSheet . absoluteFill , styles . splashScreenHider , opacityStyle ] } >
5965 < Reanimated . View style = { scaleStyle } >
6066 < ImageSVG
61- onLoadEnd = { hide }
6267 contentFit = "fill"
6368 style = { { width : 100 * logoSizeRatio , height : 100 * logoSizeRatio } }
6469 src = { Logo }
0 commit comments