-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathApp.tsx
80 lines (72 loc) · 2.49 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// React Redux Persist State
import { SafeAreaProvider } from "react-native-safe-area-context";
import { Provider } from "react-redux";
import { persistStore } from "redux-persist";
import { PersistGate } from "redux-persist/integration/react";
import axios, { AxiosError } from "axios";
import Constants from "expo-constants";
import { useEffect } from "react";
import firebaseInit from "./src/firebase/config";
import { logAxiosError } from "./src/utils";
import Stack from "./src/screens/Stacks/StackNavigator";
import MergedStacks from "./src/screens/Stacks/MergedStacks";
import useCachedResources from "./src/hooks/useCachedResources";
import { store } from "./src/redux/store";
// Time Analytics
import NavigationContainerWithTracking from "./src/components/NavigationContainerWithTracking";
import AuthGuard from "./src/screens/Auth/AuthGuard";
const persistor = persistStore(store);
export default function App() {
// For local testing add your IP address here
const { isLoadingComplete } = useCachedResources();
useEffect(() => {
firebaseInit();
}, []);
if (!isLoadingComplete) {
return null;
}
return (
<Provider store={store}>
<PersistGate persistor={persistor} loading={null}>
<SafeAreaProvider>
<AuthGuard>
<NavigationContainerWithTracking>
<Stack.Navigator
// Consistent styling across all stacked screens
screenOptions={{
headerBackTitleVisible: false,
gestureEnabled: false,
headerTintColor: "black",
headerLeft: null,
headerStyle: {
backgroundColor: "white",
},
headerTitleStyle: {
fontWeight: "bold",
fontSize: 22,
color: "black",
},
headerTitleAlign: "center",
animation: "fade",
headerShown: false,
}}
>
{MergedStacks}
</Stack.Navigator>
</NavigationContainerWithTracking>
</AuthGuard>
</SafeAreaProvider>
</PersistGate>
</Provider>
);
}
axios.defaults.baseURL = Constants.expoConfig.extra.AXIOS_BASEURL as string;
// Add a request interceptor
axios.interceptors.request.use(
(config) => config,
(error: AxiosError) => {
// Do something with request error
logAxiosError(error);
return Promise.reject(error);
},
);