-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
43 lines (40 loc) · 1.12 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
import {
createNavigationContainerRef,
NavigationContainer,
} from "@react-navigation/native";
import { StatusBar } from "expo-status-bar";
import { useState } from "react";
import { StyleSheet } from "react-native";
import { Provider } from "react-redux";
import TabNavigator from "./src/navigations/TabNavigator";
import store from "./src/redux/store";
const App = () => {
const [routeName, setRouteName] = useState("");
const ref = createNavigationContainerRef();
return (
<Provider store={store}>
<NavigationContainer
ref={ref}
onReady={() => {
setRouteName((ref as any).getCurrentRoute().name); // TODO
}}
onStateChange={async () => {
const currentRouteName = (ref as any).getCurrentRoute().name;
setRouteName(currentRouteName);
}}
>
<TabNavigator routeName={routeName} />
<StatusBar style="auto" />
</NavigationContainer>
</Provider>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
});
export default App;