From dcd9021be246f617aa5605568844d178e57d3217 Mon Sep 17 00:00:00 2001 From: Vinicius Souza Date: Wed, 30 Oct 2024 10:34:49 -0300 Subject: [PATCH] feat(auth): create hook for auth context --- src/hooks/useAuth.tsx | 9 +++++++++ src/routes/index.tsx | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 src/hooks/useAuth.tsx diff --git a/src/hooks/useAuth.tsx b/src/hooks/useAuth.tsx new file mode 100644 index 0000000..346cb66 --- /dev/null +++ b/src/hooks/useAuth.tsx @@ -0,0 +1,9 @@ +import { useContext } from 'react'; + +import { AuthContext } from '@contexts/AuthContext'; + +export function useAuth() { + const context = useContext(AuthContext); + + return context; +} diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 6ed94d5..72874f5 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -5,13 +5,13 @@ import { Box } from '@gluestack-ui/themed'; import { AuthRoutes } from './auth.routes'; import { AppRoutes } from './app.routes'; -import { AuthContext } from '@contexts/AuthContext'; - import { gluestackUIConfig } from '../../config/gluestack-ui.config'; +import { useAuth } from '@hooks/useAuth'; export function Routes() { const theme = DefaultTheme; - const contextData = useContext(AuthContext); + const { user } = useAuth(); + console.debug(user); theme.colors.background = gluestackUIConfig.tokens.colors.gray700;