From cc147218065a4a8a6d508dafe6d1b8b9116827a5 Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Wed, 3 Jul 2024 14:22:18 -0700 Subject: [PATCH] adding app context to mobile app --- app/client/mobile/App.tsx | 64 ++++++++++--------- app/client/mobile/src/context/AppContext.js | 14 ++++ .../mobile/src/context/useAppContext.hook.js | 18 ++++++ 3 files changed, 66 insertions(+), 30 deletions(-) create mode 100644 app/client/mobile/src/context/AppContext.js create mode 100644 app/client/mobile/src/context/useAppContext.hook.js diff --git a/app/client/mobile/App.tsx b/app/client/mobile/App.tsx index 125fe1b9..f3644b51 100644 --- a/app/client/mobile/App.tsx +++ b/app/client/mobile/App.tsx @@ -6,6 +6,8 @@ */ import React from 'react'; +import { AppContextProvider } from './src/context/AppContext'; + import type {PropsWithChildren} from 'react'; import { SafeAreaView, @@ -63,36 +65,38 @@ function App(): React.JSX.Element { }; return ( - - - -
- -
- Edit App.tsx to change this - screen and then come back to see your edits. -
-
- -
-
- -
-
- Read the docs to discover what to do next: -
- -
- - + + + + +
+ +
+ Edit App.tsx to change this + screen and then come back to see your edits. +
+
+ +
+
+ +
+
+ Read the docs to discover what to do next: +
+ +
+ + + ); } diff --git a/app/client/mobile/src/context/AppContext.js b/app/client/mobile/src/context/AppContext.js new file mode 100644 index 00000000..665eec18 --- /dev/null +++ b/app/client/mobile/src/context/AppContext.js @@ -0,0 +1,14 @@ +import { createContext } from 'react'; +import { useAppContext } from './useAppContext.hook'; + +export const AppContext = createContext({}); + +export function AppContextProvider({ children }) { + const { state, actions } = useAppContext(); + return ( + + {children} + + ); +} + diff --git a/app/client/mobile/src/context/useAppContext.hook.js b/app/client/mobile/src/context/useAppContext.hook.js new file mode 100644 index 00000000..71307a71 --- /dev/null +++ b/app/client/mobile/src/context/useAppContext.hook.js @@ -0,0 +1,18 @@ +import { useState, useEffect } from 'react'; + +import { DatabagSDK } from 'databag-client-sdk'; + +export function useAppContext() { + const [state, setState] = useState({ + }); + + useEffect(() => { + console.log("IN APP CONTEXT"); + }, []); + + const actions = { + } + + return { state, actions } +} +