diff --git a/src/components/FullscreenLoadingIndicator.tsx b/src/components/FullscreenLoadingIndicator.tsx index e94cf16a93b8..44dc1d87eb2a 100644 --- a/src/components/FullscreenLoadingIndicator.tsx +++ b/src/components/FullscreenLoadingIndicator.tsx @@ -19,6 +19,9 @@ type FullScreenLoadingIndicatorProps = { /** Size of the icon */ iconSize?: FullScreenLoadingIndicatorIconSize; + /** Whether the "Go Back" button appears after a timeout. */ + shouldUseGoBackButton?: boolean; + /** The ID of the test to be used for testing */ testID?: string; @@ -26,17 +29,27 @@ type FullScreenLoadingIndicatorProps = { extraLoadingContext?: ExtraLoadingContext; }; -function FullScreenLoadingIndicator({style, iconSize = CONST.ACTIVITY_INDICATOR_SIZE.LARGE, testID = '', extraLoadingContext}: FullScreenLoadingIndicatorProps) { +function FullScreenLoadingIndicator({ + style, + iconSize = CONST.ACTIVITY_INDICATOR_SIZE.LARGE, + shouldUseGoBackButton = false, + testID = '', + extraLoadingContext, +}: FullScreenLoadingIndicatorProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const [showGoBackButton, setShowGoBackButton] = useState(false); useEffect(() => { + if (!shouldUseGoBackButton) { + return; + } + const timeoutId = setTimeout(() => { setShowGoBackButton(true); }, CONST.TIMING.ACTIVITY_INDICATOR_TIMEOUT); return () => clearTimeout(timeoutId); - }, []); + }, [shouldUseGoBackButton]); return (