From 2ed6de812940bd8e025cca90c7f892eb4504400e Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Sun, 25 Feb 2024 22:50:12 +0100 Subject: [PATCH] Fix: VBA - Background page is reloading when proceeding through VBA flow --- src/pages/workspace/WorkspacePageWithSections.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspacePageWithSections.tsx b/src/pages/workspace/WorkspacePageWithSections.tsx index b9b14e27d01d..32b76ef46202 100644 --- a/src/pages/workspace/WorkspacePageWithSections.tsx +++ b/src/pages/workspace/WorkspacePageWithSections.tsx @@ -1,3 +1,4 @@ +import {useIsFocused} from '@react-navigation/native'; import type {ReactNode} from 'react'; import React, {useEffect, useMemo, useRef} from 'react'; import {View} from 'react-native'; @@ -121,6 +122,7 @@ function WorkspacePageWithSections({ const content = typeof children === 'function' ? children(hasVBA, policyID, isUsingECard) : children; const {isSmallScreenWidth} = useWindowDimensions(); const firstRender = useRef(true); + const isFocused = useIsFocused(); useEffect(() => { // Because isLoading is false before merging in Onyx, we need firstRender ref to display loading page as well before isLoading is change to true @@ -163,7 +165,7 @@ function WorkspacePageWithSections({ onBackButtonPress={() => Navigation.goBack(backButtonRoute ?? ROUTES.WORKSPACE_INITIAL.getRoute(policyID))} icon={icon ?? undefined} /> - {(isLoading || firstRender.current) && shouldShowLoading ? ( + {(isLoading || firstRender.current) && shouldShowLoading && isFocused ? ( ) : ( <>