Skip to content

Commit

Permalink
Merge pull request Expensify#37188 from rayane-djouah/Fix-VBA-Backgro…
Browse files Browse the repository at this point in the history
…und-page-is-reloading-when-proceeding-through-VBA-flow

Fix: VBA - Background page is reloading when proceeding through VBA flow
  • Loading branch information
cristipaval authored Feb 28, 2024
2 parents e5b3eb2 + ea2eb7d commit 1649978
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/pages/workspace/WorkspacePageWithSections.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ? (
<FullScreenLoadingIndicator style={[styles.flex1, styles.pRelative]} />
) : (
<>
Expand Down

0 comments on commit 1649978

Please sign in to comment.