-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
65 lines (57 loc) · 1.78 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
import React, { useEffect, useState } from "react";
import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
import * as Font from "expo-font";
import { NavigationContainer } from "@react-navigation/native";
import { StatusBar } from "expo-status-bar";
import useNotification from "@/hooks/useNotification";
import ToastManager from "@/components/common/toast";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import { getToken } from "@/utils";
import MainNavigator from "@/navigation/Navigation";
const loadFonts = () => {
return Font.loadAsync({
WantedSans: require("assets/fonts/WantedSans-Regular.ttf"),
});
};
const queryClient = new QueryClient({
defaultOptions: {
queries: {
retry: true,
retryDelay: 300,
staleTime: 10000,
},
},
});
function App() {
const [fontsLoaded, setFontsLoaded] = useState(false);
const [token, setTokens] = useState<null | string | undefined>(undefined);
useEffect(() => {
const tokenfn = async () => {
const { accessToken } = await getToken();
setTokens(accessToken);
};
tokenfn();
}, []);
useEffect(() => {
loadFonts()
.then(() => setFontsLoaded(true))
.catch((error) => console.error(error));
}, []);
// useNotification을 항상 호출
useNotification();
if (!fontsLoaded || token === undefined) {
return <></>; // 폰트가 로드되지 않은 경우 빈 화면 반환
}
return (
<QueryClientProvider client={queryClient}>
<GestureHandlerRootView style={{ flex: 1 }}>
<NavigationContainer>
<ToastManager />
<StatusBar style={"auto"} />
<MainNavigator token={token} />
</NavigationContainer>
</GestureHandlerRootView>
</QueryClientProvider>
);
}
export default App;