-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.jsx
More file actions
55 lines (49 loc) · 1.61 KB
/
App.jsx
File metadata and controls
55 lines (49 loc) · 1.61 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
import React, { useState } from "react";
import "react-native-gesture-handler";
import { Provider } from "react-redux";
import { PersistGate } from "redux-persist/integration/react";
import { persistStore } from "redux-persist";
import store from "./src/store/index";
import { StatusBar } from "react-native";
import { NavigationContainer } from "@react-navigation/native";
import Tabs from "./src/navigation/tab.js";
import AuthNavigator from "./src/navigation/AuthNavigation";
import navigationTheme from "./src/navigation/navigationTheme";
import OfflineNotice from "./src/components/OfflineNotice";
import AppLoading from "expo-app-loading";
import COLORS from "./src/assets/color/colors";
import { navigationRef } from "./src/navigationRef";
import { useSelector } from "react-redux";
let persistor = persistStore(store);
const App = () => {
const [isReady, setIsReady] = useState(false);
const token = useSelector((state) => state.auth.token);
if (!isReady) {
return (
<AppLoading
startAsync={() => console.log("Ready")}
onFinish={() => setIsReady(true)}
onError={console.warn}
/>
);
}
return (
<>
<OfflineNotice />
<NavigationContainer ref={navigationRef} theme={navigationTheme}>
<StatusBar backgroundColor={COLORS.dark} barStyle="light-content" />
{token ? <Tabs /> : <AuthNavigator />}
</NavigationContainer>
</>
);
};
const AppWrapper = () => {
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<App />
</PersistGate>
</Provider>
);
};
export default AppWrapper;