-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
75 lines (64 loc) · 2.16 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
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, {Component} from 'react';
import {Text, TextInput} from 'react-native';
import {Provider} from 'react-redux';
import {ThemeProvider} from 'react-native-elements';
import AppContainer from './src/navigation/index';
import SplashScreen from 'react-native-splash-screen';
import {PersistGate} from 'redux-persist/integration/react';
import theme from './src/config/theme';
import configureStore from './src/redux/store/configureStore';
import {getActiveRouteName} from './src/common/utils';
import NavigationService from './src/common/NavigationService';
const {persistor, store} = configureStore();
class App extends Component {
constructor(props) {
super(props);
this.state = {};
this.disableScaling();
}
componentDidMount() {
SplashScreen.hide();
}
disableScaling = () => {
Text.defaultProps = Text.defaultProps || {};
Text.defaultProps.allowFontScaling = false;
TextInput.defaultProps = TextInput.defaultProps || {};
TextInput.defaultProps.allowFontScaling = false;
};
onNavigationStateChange = (prevState, currentState, action) => {
const currentRouteName = getActiveRouteName(currentState);
const previousRouteName = getActiveRouteName(prevState);
if (previousRouteName !== currentRouteName) {
// the line below uses the @react-native-firebase/analytics tracker
// change the tracker here to use other Mobile analytics SDK.
// eslint-disable-next-line no-console
console.log('setCurrentScreen', currentRouteName);
// firebase.analytics().setCurrentScreen(currentRouteName, currentRouteName);
}
};
onRef = navigatorRef => {
NavigationService.setTopLevelNavigator(navigatorRef);
};
render() {
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<ThemeProvider theme={theme}>
<AppContainer
ref={this.onRef}
onNavigationStateChange={this.onNavigationStateChange}
/>
</ThemeProvider>
</PersistGate>
</Provider>
);
}
}
export default App;