-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
51 lines (45 loc) · 1.66 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
import React, { useEffect, useRef } from "react";
import { SafeAreaView, StyleSheet } from "react-native";
import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/integration/react';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { store, persistor } from './src/redux/store'
import RootStack from "./src/routes/RootStack";
import { NavigationContainer, DarkTheme } from '@react-navigation/native';
import SplashScreen from 'react-native-splash-screen';
import { CommonActions, createNavigationContainerRef } from '@react-navigation/native'
import { useDispatch } from 'react-redux';
import { changeSelectedScreen } from "./src/redux/actions";
const App = () => {
const navigationRef = createNavigationContainerRef();
// const dispatch = useDispatch();
useEffect(() => {
setTimeout(() => {
SplashScreen.hide()
}, 2000)
}, [])
const onStateChange = async () => {
const currentRouteName = navigationRef?.current?.getCurrentRoute()?.name
console.log('screen', currentRouteName);
store.dispatch(changeSelectedScreen(currentRouteName))
}
return (
<SafeAreaProvider style={{ backgroundColor: 'black' }}>
<SafeAreaView style={styles.container}>
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<NavigationContainer ref={navigationRef} theme={DarkTheme} onStateChange={onStateChange}>
<RootStack />
</NavigationContainer>
</PersistGate>
</Provider>
</SafeAreaView>
</SafeAreaProvider>
);
};
const styles = StyleSheet.create({
container: {
flex: 1
}
});
export default App;