From 2c24639c1dc4d7dd5af737f5328c26bbcc2e58a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Warcho=C5=82?= <61014013+war-in@users.noreply.github.com> Date: Mon, 30 Mar 2026 16:06:11 +0200 Subject: [PATCH] Revert "performance: Always mount `SplashScreenHider` and control hide timing via prop instead of conditional rendering" --- src/Expensify.tsx | 9 +-------- .../SplashScreenHider/index.native.tsx | 17 ++++++----------- src/components/SplashScreenHider/index.tsx | 14 ++++---------- src/components/SplashScreenHider/types.ts | 3 --- 4 files changed, 11 insertions(+), 32 deletions(-) diff --git a/src/Expensify.tsx b/src/Expensify.tsx index 82900c0ef0a6..c8f204c5012f 100644 --- a/src/Expensify.tsx +++ b/src/Expensify.tsx @@ -199,9 +199,7 @@ function Expensify() { Navigation.setIsNavigationReady(); }, []); - const [splashHideHasBeenCalled, setSplashHideHasBeenCalled] = useState(false); const onSplashHide = useCallback(() => { - setSplashHideHasBeenCalled(true); setSplashScreenState(CONST.BOOT_SPLASH_STATE.HIDDEN); endSpan(CONST.TELEMETRY.SPAN_OD_ND_TRANSITION); endSpan(CONST.TELEMETRY.SPAN_APP_STARTUP); @@ -294,12 +292,7 @@ function Expensify() { initialUrl={initialUrl} /> )} - {!splashHideHasBeenCalled && ( - - )} + {shouldHideSplash && } ); } diff --git a/src/components/SplashScreenHider/index.native.tsx b/src/components/SplashScreenHider/index.native.tsx index 810bff807a03..100bc59353ff 100644 --- a/src/components/SplashScreenHider/index.native.tsx +++ b/src/components/SplashScreenHider/index.native.tsx @@ -1,4 +1,4 @@ -import {useEffect, useEffectEvent, useRef} from 'react'; +import {useCallback, useRef} from 'react'; import type {ViewStyle} from 'react-native'; import {StyleSheet} from 'react-native'; import Reanimated, {Easing, useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated'; @@ -9,7 +9,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import BootSplash from '@libs/BootSplash'; import type {SplashScreenHiderProps, SplashScreenHiderReturnType} from './types'; -function SplashScreenHider({shouldHideSplash, onHide}: SplashScreenHiderProps): SplashScreenHiderReturnType { +function SplashScreenHider({onHide = () => {}}: SplashScreenHiderProps): SplashScreenHiderReturnType { const styles = useThemeStyles(); const logoSizeRatio = BootSplash.logoSizeRatio || 1; @@ -24,7 +24,8 @@ function SplashScreenHider({shouldHideSplash, onHide}: SplashScreenHiderProps): })); const hideHasBeenCalled = useRef(false); - const hide = useEffectEvent(() => { + + const hide = useCallback(() => { // hide can only be called once if (hideHasBeenCalled.current) { return; @@ -51,19 +52,13 @@ function SplashScreenHider({shouldHideSplash, onHide}: SplashScreenHiderProps): ), ); }); - }); - - useEffect(() => { - if (!shouldHideSplash) { - return; - } - hide(); - }, [shouldHideSplash]); + }, [opacity, scale, onHide]); return ( { - BootSplash.hide().then(() => onHide()); - }); +function SplashScreenHider({onHide = () => {}}: SplashScreenHiderProps): SplashScreenHiderReturnType { useEffect(() => { - if (!shouldHideSplash) { - return; - } - hide(); - }, [shouldHideSplash]); + BootSplash.hide().then(() => onHide()); + }, [onHide]); return null; } diff --git a/src/components/SplashScreenHider/types.ts b/src/components/SplashScreenHider/types.ts index 360904feb809..e48bbdcee307 100644 --- a/src/components/SplashScreenHider/types.ts +++ b/src/components/SplashScreenHider/types.ts @@ -1,9 +1,6 @@ import type {ReactNode} from 'react'; type SplashScreenHiderProps = { - /** Whether the splash screen should be hidden */ - shouldHideSplash: boolean; - /** Splash screen has been hidden */ onHide: () => void; };