From bdc8e376fe086113ffeb7179c73897d41e1d44ac Mon Sep 17 00:00:00 2001 From: G Date: Sat, 27 Apr 2024 23:38:11 +0000 Subject: [PATCH] go directly to the home page for logged in user WHEN user is logged in 🙃 --- src/navigations/InitialNavigationHandler.tsx | 11 +++++++++++ src/screens/HomeUserNotLoggedIn.tsx | 7 +++++++ 2 files changed, 18 insertions(+) create mode 100644 src/navigations/InitialNavigationHandler.tsx diff --git a/src/navigations/InitialNavigationHandler.tsx b/src/navigations/InitialNavigationHandler.tsx new file mode 100644 index 0000000..5562e4d --- /dev/null +++ b/src/navigations/InitialNavigationHandler.tsx @@ -0,0 +1,11 @@ +import { useUserAuthenticationContext } from "@/contexts/UserAuthenticationContext"; +import UnloggedUserStackNavigation from "./UnloggedUserStackNavigation"; + +const InitialNavigationHandler = () => { + const { isAuthenticated } = useUserAuthenticationContext(); + console.log("isAuthenticated", isAuthenticated); + + return ; +}; + +export default InitialNavigationHandler; diff --git a/src/screens/HomeUserNotLoggedIn.tsx b/src/screens/HomeUserNotLoggedIn.tsx index a10fca3..02f0d35 100644 --- a/src/screens/HomeUserNotLoggedIn.tsx +++ b/src/screens/HomeUserNotLoggedIn.tsx @@ -1,3 +1,4 @@ +import { useUserAuthenticationContext } from "@/contexts/UserAuthenticationContext"; import type { UnloggedUserStackScreenComponentProps } from "@/navigations/Types"; import Button from "@components/Button"; import Box from "@components/bases/Box"; @@ -6,6 +7,12 @@ import { Image, StyleSheet } from "react-native"; const HomeUserNotLoggedIn: UnloggedUserStackScreenComponentProps<"homeUserNotLoggedIn"> = ({ navigation, }) => { + const { isAuthenticated } = useUserAuthenticationContext(); + + if (isAuthenticated) { + navigation.replace("bottomTabs"); + } + return ( -- libgit2 0.27.1