From 55d037f6f4f1d103eb46da198955e6d8ce4894b9 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Mon, 31 Jan 2022 23:03:23 -0800 Subject: [PATCH] Added a context to track logged-in and editable state --- context/AppContext.tsx | 10 ++++++++++ pages/_app.tsx | 16 ++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 context/AppContext.tsx diff --git a/context/AppContext.tsx b/context/AppContext.tsx new file mode 100644 index 00000000..ab66c95c --- /dev/null +++ b/context/AppContext.tsx @@ -0,0 +1,10 @@ +import { createContext } from 'react' + +const AppContext = createContext({ + authenticated: false, + editable: false, + setAuthenticated: (auth: boolean) => {}, + setEditable: (editable: boolean) => {} +}) + +export default AppContext \ No newline at end of file diff --git a/pages/_app.tsx b/pages/_app.tsx index 3471ecc3..f01ddfaa 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,15 +1,23 @@ import '../styles/globals.scss' -import type { AppProps } from 'next/app' +import { useState } from 'react' import { CookiesProvider } from 'react-cookie' + import Layout from '~components/Layout' +import AppContext from '~context/AppContext' + +import type { AppProps } from 'next/app' function MyApp({ Component, pageProps }: AppProps) { + const [authenticated, setAuthenticated] = useState(false) + const [editable, setEditable] = useState(false) return ( - - - + + + + + ) }