-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
54 lines (49 loc) · 1.72 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
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 {createNavigationContainerRef} from '@react-navigation/native';
import {changeSelectedScreen} from './src/redux/actions';
import {AxiosInterceptor} from './src/api_calls/axios-instance';
const App = () => {
const navigationRef = createNavigationContainerRef();
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}>
<AxiosInterceptor>
<RootStack />
</AxiosInterceptor>
</NavigationContainer>
</PersistGate>
</Provider>
</SafeAreaView>
</SafeAreaProvider>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
export default App;