From 527c1fc3ec5cc694e3fe889e16d2da7dc6ccdc19 Mon Sep 17 00:00:00 2001 From: Jake McCoy - New Date: Thu, 9 May 2024 15:19:27 +1000 Subject: [PATCH] Add context to the layout component --- app/_layout.tsx | 87 ++++++++++++++++++++++++---------------------- contextManager.tsx | 56 +---------------------------- 2 files changed, 46 insertions(+), 97 deletions(-) diff --git a/app/_layout.tsx b/app/_layout.tsx index 65f6276..3275d23 100644 --- a/app/_layout.tsx +++ b/app/_layout.tsx @@ -11,6 +11,7 @@ import { useEffect } from "react"; import { useColorScheme } from "@/components/useColorScheme"; import { SB_COLOR_SCHEME } from "@/constants"; +import { UserContextProvider } from "@/contextManager"; export { // Catch any errors thrown by the Layout component. @@ -54,48 +55,50 @@ function RootLayoutNav() { return ( - - - - - - - - + + + + + + + + + + ); } diff --git a/contextManager.tsx b/contextManager.tsx index 526a3fc..82644c0 100644 --- a/contextManager.tsx +++ b/contextManager.tsx @@ -25,61 +25,7 @@ export interface User { //const UserContext = createContext(null); const UserContext = createContext(null as any); -function UserProvider({ children }: any) { - // const [user, setUser] = useState(null as any); - - // const setName = (firstName: string, lastName: string) => { - // setUser((prevUser) => ({ - // ...prevUser, - // firstName, - // lastName, - // })); - // }; - - // const setEmail = (email: string) => { - // setUser((prevUser) => ({ - // ...prevUser, - // email - // })); - // }; - - // const setPhone = (phone: number) => { - // setUser((prevUser) => ({ - // ...prevUser, - // phone - // })); - // }; - - // const setAddress = (address: string) => { - // setUser((prevUser) => ({ - // ...prevUser, - // address - // })); - // }; - - // const setPassword = (password: string) => { - // setUser((prevUser) => ({ - // ...prevUser, - // password - // })); - // }; - - // const setIsMember = (isMember: boolean) => { - // setUser((prevUser) => ({ - // ...prevUser, - // isMember - // })); - // }; - - // const addCard = (newCard: Card) => { - // setUser((prevUser) => ({ - // ...prevUser, - // cards: [...(prevUser?.cards || []), newCard], - // })); - // }; - - // const value = user ? { ...user, setName, setEmail, setAddress, setPassword, setIsMember, addCard} : null; - +export function UserContextProvider({ children }: any) { const value = useUser(); return {children};