-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
45 lines (39 loc) · 1.41 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* eslint-disable prettier/prettier */
import "expo-dev-client";
import { firebase } from "@react-native-firebase/app-check";
import { StatusBar } from "expo-status-bar";
import { SafeAreaProvider } from "react-native-safe-area-context";
import useCachedResources from "./hooks/useCachedResources";
import Navigation from "./navigation";
import { AuthContext, authMachine } from "./utils/machines/authMachine";
import { useEffect, useRef } from "react";
import { rnfbProvider } from "./utils/appCheck";
import { interpret } from "xstate";
const authService = interpret(authMachine);
authService.start();
export default function App() {
const isLoadingComplete = useCachedResources();
const initialized = useRef(false);
// Initialize App Check
useEffect(() => {
if (initialized.current === false) {
console.log("Initializing App Check");
firebase.appCheck().initializeAppCheck({
provider: rnfbProvider,
});
initialized.current = true;
}
}, [initialized, firebase]);
if (!isLoadingComplete) {
return null;
} else {
return (
<AuthContext.Provider value={authService}>
<SafeAreaProvider style={{ flex: 1, backgroundColor: "#fff" }}>
<Navigation />
<StatusBar />
</SafeAreaProvider>
</AuthContext.Provider>
);
}
}