forked from DiscipleTools/disciple-tools-mobile-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
101 lines (85 loc) · 2.77 KB
/
App.js
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import './wdyr';
import React, { useEffect } from "react";
import { LogBox, Text } from "react-native";
import * as SplashScreen from "expo-splash-screen";
import AppNavigator from "navigation/AppNavigator";
import { store, persistor } from "store/store";
import { Provider } from "react-redux";
import { PersistGate } from "redux-persist/integration/react";
import { SWRConfig } from "swr";
import Toast from "react-native-toast-message";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import { BottomSheetModalProvider } from "@gorhom/bottom-sheet";
import { AuthProvider } from "hooks/use-auth";
//import useApp from "hooks/use-app";
import useAppState from "hooks/use-app-state";
import useStyles from "hooks/use-styles";
import { toastConfig } from 'hooks/use-toast';
//import { AppConstants } from "constants";
import { enableScreens } from "react-native-screens";
enableScreens();
const StyledApp = () => {
// set default text styles
const { globalStyles } = useStyles();
Text.defaultProps = Text.defaultProps || {};
Text.defaultProps.style = { ...globalStyles.text };
return <AppNavigator />;
};
const App = () => {
// Initialize the app
//useApp();
// Dispay splash screen (keep visible until iniital screens ready to render)
useEffect(() => {
try {
(async () => {
await SplashScreen.preventAutoHideAsync();
})();
} catch (e) {
console.warn(e);
}
return;
}, []);
// Persist SWR in-memory cache to device storage on an interval
/*
useEffect(() => {
const interval = setInterval(() => {
console.log(`Persist cache (runs every ${CacheConstants.INTERVAL} ms) -`, new Date());
(async () => {
await persistCache();
})();
}, CacheConstants.INTERVAL);
return () => clearInterval(interval);
}, []);
*/
// Handle App State change(s)
useAppState();
LogBox.ignoreAllLogs();
return (
<>
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<GestureHandlerRootView style={{ flex: 1 }}>
<SWRConfig
value={{
revalidateOnFocus: true,
refreshInterval: 0, //5000, //AppConstants.REFRESH_INTERVAL,
shouldRetryOnError: false,
dedupingInterval: 2000,
focusThrottleInterval: 5000,
loadingTimeout: 10000,
}}
>
<AuthProvider>
<BottomSheetModalProvider>
<StyledApp />
</BottomSheetModalProvider>
</AuthProvider>
</SWRConfig>
</GestureHandlerRootView>
</PersistGate>
</Provider>
<Toast config={toastConfig} />
</>
);
};
export default App;