-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
91 lines (81 loc) · 2.7 KB
/
Copy pathApp.tsx
File metadata and controls
91 lines (81 loc) · 2.7 KB
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
// Import necessary dependencies
import React, { useEffect, useState } from "react";
import { View } from "react-native";
import { SafeAreaProvider } from "react-native-safe-area-context";
import { StatusBar } from "expo-status-bar";
import * as Font from "expo-font";
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
import ExpoClientConfig from "expo-constants";
import * as Sentry from "sentry-expo";
import { Provider } from "react-redux";
import { enableScreens } from "react-native-screens";
import AppNavigator from "./app/navigation/Navigator/AppNavigator";
import store from "./app/redux/store";
// Ignore TypeScript error for the next line
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// Get the release version from Expo config, or use "0.0.0" as default
const release = ExpoClientConfig.revisionId || "0.0.0";
// Initialize Sentry for error tracking in non-development environments
if (!__DEV__) {
Sentry.init({
dsn: process.env.SENTRY_DSN,
enableInExpoDevelopment: false,
debug: true,
release,
});
}
// Define the main App component
const App: React.FC = () => {
// Enable screens for better performance in React Navigation
enableScreens();
// State to track whether fonts are loaded
const [ready, setReady] = useState(false);
// Use effect hook to load fonts when component mounts
useEffect(() => {
Promise.all([
Font.loadAsync({
...Ionicons.font,
...MaterialCommunityIcons.font,
"Lato-Black": require("./assets/fonts/Lato-Black.ttf"),
"Lato-Bold": require("./assets/fonts/Lato-Bold.ttf"),
"Lato-Light": require("./assets/fonts/Lato-Light.ttf"),
"Lato-Medium": require("./assets/fonts/Lato-Regular.ttf"),
}),
])
.then(() => {
// Set ready state to true when fonts are loaded
setReady(true);
})
.catch((error) => {
// Capture any errors during font loading
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Sentry.captureException(error);
});
}, []); // Empty dependency array ensures this effect runs only once
// Initialize body with an empty View
let body = <View />;
// If fonts are loaded, render the main app content
if (ready) {
body = (
<Provider store={store}>
{/* AppNavigator is rendered regardless of __DEV__ status */}
{__DEV__ ? (
<AppNavigator />
) : (
<AppNavigator />
)}
</Provider>
);
}
// Return the main app structure
return (
<SafeAreaProvider>
<StatusBar style="dark" />
{body}
</SafeAreaProvider>
);
};
// Export the App component as default
export default App;