1+ import { useRoute } from '@react-navigation/native' ;
12import React from 'react' ;
23import type { FullPageNotFoundViewProps } from '@components/BlockingViews/FullPageNotFoundView' ;
34import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView' ;
@@ -7,6 +8,8 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
78import Navigation from '@libs/Navigation/Navigation' ;
89import useAbsentPageSpan from '@libs/telemetry/useAbsentPageSpan' ;
910import ONYXKEYS from '@src/ONYXKEYS' ;
11+ import ROUTES from '@src/ROUTES' ;
12+ import SCREENS from '@src/SCREENS' ;
1013
1114type NotFoundPageProps = {
1215 onBackButtonPress ?: ( ) => void ;
@@ -21,6 +24,9 @@ function NotFoundPage({onBackButtonPress = () => Navigation.goBack(), isReportRe
2124 const { isSmallScreenWidth} = useResponsiveLayout ( ) ;
2225 const topmostReportId = Navigation . getTopmostReportId ( ) ;
2326 const [ report ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ topmostReportId } ` ) ;
27+ const route = useRoute ( ) ;
28+ const isOnGenericErrorScreen = route . name === SCREENS . NOT_FOUND ;
29+
2430 useAbsentPageSpan ( ) ;
2531
2632 return (
@@ -45,7 +51,7 @@ function NotFoundPage({onBackButtonPress = () => Navigation.goBack(), isReportRe
4551 } }
4652 // eslint-disable-next-line react/jsx-props-no-spreading
4753 { ...fullPageNotFoundViewProps }
48- onLinkPress = { fullPageNotFoundViewProps . onLinkPress }
54+ onLinkPress = { isOnGenericErrorScreen ? ( ) => Navigation . goBack ( ROUTES . HOME ) : fullPageNotFoundViewProps . onLinkPress }
4955 />
5056 </ ScreenWrapper >
5157 ) ;
0 commit comments