-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
108 lines (101 loc) · 3.49 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
102
103
104
105
106
107
108
import "react-native-gesture-handler";
import { NavigationContainer } from "@react-navigation/native";
import { ThemeProvider } from "styled-components/native";
import KakaoLogin from "./Screen/Login/KakaoLogin";
import CommunityRoutes from "./Navigation/CommunityRoutes";
import Theme from "./Theme/Theme";
import MainRoutes from "./Navigation/MainRoutes";
import Login from "./Screen/Login/Login";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { Provider, useAtom, useAtomValue, useSetAtom } from "jotai";
import KakaoLogout from "./Screen/Login/KakaoLogout";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import { createStackNavigator } from "@react-navigation/stack";
import { isLoggedInAtom } from "./Jotai/atoms/authAtoms";
import MainTab from "./Navigation/MainTab";
import { Suspense, useEffect } from "react";
import AsyncStorage from "@react-native-async-storage/async-storage";
import IsLoading from "./Common/Loading/IsLoading";
import ScreenHeader from "./Common/ScreenHeader/ScreenHeader";
import GeneralLogin from "./Screen/Login/GeneralSignUp";
import GeneralSignUp from "./Screen/Login/GeneralSignUp";
// const Tab = createBottomTabNavigator();
const AuthStack = createStackNavigator();
const queryClient = new QueryClient({
defaultOptions: {
queries: {
suspense: true,
},
},
});
export default function App() {
// Sentry.init({
// dsn: process.env.REACT_APP_SENTRY_DSN,
// environment: "production",
// normalizeDepth: 6,
// });
// const [isLoggedIn, setIsLoggedIn] = useState(true);
const isLoggedIn = useAtomValue(isLoggedInAtom);
const setIsLoggedIn = useSetAtom(isLoggedInAtom);
useEffect(() => {
// Fetch the token from storage then navigate to our appropriate place
const getTokenAsync = async () => {
let userToken;
try {
userToken = await AsyncStorage.getItem("accessToken");
} catch (e) {
// Restoring token failed
}
if (userToken) {
setIsLoggedIn(true);
} else {
setIsLoggedIn(false);
}
};
getTokenAsync();
}, []);
return (
<QueryClientProvider client={queryClient}>
<NavigationContainer>
<ThemeProvider theme={Theme}>
<Suspense fallback={<IsLoading />}>
<Provider>
<AuthStack.Navigator
initialRouteName="Login"
screenOptions={{
headerStyle: {
backgroundColor: "#48B7E2",
},
headerLeft: false,
}}
>
<AuthStack.Screen
name="MainTab"
component={MainTab}
options={{
headerTitle: () => <ScreenHeader />,
}}
/>
<AuthStack.Screen
name="Login"
component={Login}
options={{ headerShown: false }}
/>
{/* <AuthStack.Screen
name="GeneralSignUp"
component={GeneralSignUp}
options={{ headerShown: false }}
/> */}
<AuthStack.Screen
name="KakaoLogin"
component={KakaoLogin}
options={{ headerShown: false }}
/>
</AuthStack.Navigator>
</Provider>
</Suspense>
</ThemeProvider>
</NavigationContainer>
</QueryClientProvider>
);
}