diff --git a/src/libs/Navigation/AppNavigator/Navigators/ReportsSplitNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/ReportsSplitNavigator.tsx index daaabf1094b4..c83816a21b5d 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/ReportsSplitNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/ReportsSplitNavigator.tsx @@ -1,42 +1,19 @@ -import {useNavigationState, useRoute} from '@react-navigation/native'; import React, {useRef} from 'react'; -import {Freeze} from 'react-freeze'; import FocusTrapForScreens from '@components/FocusTrap/FocusTrapForScreen'; import useActiveWorkspace from '@hooks/useActiveWorkspace'; import usePermissions from '@hooks/usePermissions'; -import memoize from '@libs/memoize'; import createSplitStackNavigator from '@libs/Navigation/AppNavigator/createSplitStackNavigator'; +import FreezeWrapper from '@libs/Navigation/AppNavigator/FreezeWrapper'; import getCurrentUrl from '@libs/Navigation/currentUrl'; import shouldOpenOnAdminRoom from '@libs/Navigation/shouldOpenOnAdminRoom'; import type {ReportsSplitNavigatorParamList} from '@libs/Navigation/types'; -import {isFullScreenName} from '@libs/NavigationUtils'; import * as ReportUtils from '@libs/ReportUtils'; import CONST from '@src/CONST'; import SCREENS from '@src/SCREENS'; import type ReactComponentModule from '@src/types/utils/ReactComponentModule'; -function FrozenScreen(WrappedComponent: React.ComponentType, freeze: boolean) { - return (props: TProps) => ( - - - - ); -} - -function freezeScreenWithLazyLoading(lazyComponent: () => React.ComponentType, freeze: boolean) { - return memoize( - () => { - const Component = lazyComponent(); - return FrozenScreen(Component, freeze); - }, - {monitoringName: 'freezeScreenWithLazyLoading'}, - ); -} - const loadReportScreen = () => require('../../../../pages/home/ReportScreen').default; +const loadSidebarScreen = () => require('@pages/home/sidebar/SidebarScreen').default; const Stack = createSplitStackNavigator(); @@ -47,8 +24,8 @@ function ReportsSplitNavigator() { let initialReportID: string | undefined; const isInitialRender = useRef(true); - const currentRoute = useRoute(); - + // TODO: Figure out if compiler affects this code. + // eslint-disable-next-line react-compiler/react-compiler if (isInitialRender.current) { const currentURL = getCurrentUrl(); if (currentURL) { @@ -60,18 +37,12 @@ function ReportsSplitNavigator() { initialReportID = initialReport?.reportID ?? ''; } + // eslint-disable-next-line react-compiler/react-compiler isInitialRender.current = false; } - const shouldFreeze = useNavigationState((state) => { - const lastFullScreenRoute = state.routes.findLast((route) => isFullScreenName(route.name)); - return lastFullScreenRoute?.key !== currentRoute.key; - }); - - const getSidebarScreen = freezeScreenWithLazyLoading(() => require('@pages/home/sidebar/SidebarScreen').default, shouldFreeze); - return ( - + - + ); } diff --git a/src/pages/Search/SearchPage.tsx b/src/pages/Search/SearchPage.tsx index 11c7a45f33b3..df425c23562f 100644 --- a/src/pages/Search/SearchPage.tsx +++ b/src/pages/Search/SearchPage.tsx @@ -15,6 +15,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import {turnOffMobileSelectionMode} from '@libs/actions/MobileSelectionMode'; import BottomTabBar from '@libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar'; import TopBar from '@libs/Navigation/AppNavigator/createCustomBottomTabNavigator/TopBar'; +import FreezeWrapper from '@libs/Navigation/AppNavigator/FreezeWrapper'; import Navigation from '@libs/Navigation/Navigation'; import type {AuthScreensParamList} from '@libs/Navigation/types'; import * as SearchQueryUtils from '@libs/SearchQueryUtils'; @@ -58,54 +59,56 @@ function SearchPage({route}: SearchPageProps) { } return ( - - {!!queryJSON && ( - - - {/* {!selectionMode?.isEnabled && queryJSON ? ( */} - {queryJSON ? ( - - + + {!!queryJSON && ( + + + {/* {!selectionMode?.isEnabled && queryJSON ? ( */} + {queryJSON ? ( + + + + + ) : ( + { + clearSelectedTransactions(); + turnOffMobileSelectionMode(); + }} /> - - - ) : ( - { - clearSelectedTransactions(); - turnOffMobileSelectionMode(); - }} + )} + + + + - )} - + + + - - - - - - - )} - + )} + + ); }