-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42532 from rezkiy37/refactor/report-screen-and-lhn
perf: Optimize AppNavigator
- Loading branch information
Showing
2 changed files
with
55 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React, {memo, useContext, useEffect} from 'react'; | ||
import {NativeModules} from 'react-native'; | ||
import {InitialURLContext} from '@components/InitialURLContextProvider'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
|
||
type AppNavigatorProps = { | ||
/** If we have an authToken this is true */ | ||
authenticated: boolean; | ||
}; | ||
|
||
function AppNavigator({authenticated}: AppNavigatorProps) { | ||
const initUrl = useContext(InitialURLContext); | ||
|
||
useEffect(() => { | ||
if (!NativeModules.HybridAppModule || !initUrl) { | ||
return; | ||
} | ||
|
||
Navigation.isNavigationReady().then(() => { | ||
Navigation.navigate(initUrl); | ||
}); | ||
}, [initUrl]); | ||
|
||
if (authenticated) { | ||
const AuthScreens = require('./AuthScreens').default; | ||
|
||
// These are the protected screens and only accessible when an authToken is present | ||
return <AuthScreens />; | ||
} | ||
|
||
const PublicScreens = require('./PublicScreens').default; | ||
|
||
return <PublicScreens />; | ||
} | ||
|
||
AppNavigator.displayName = 'AppNavigator'; | ||
|
||
export default memo(AppNavigator); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters