-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
58 lines (50 loc) · 1.79 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
import React from 'react';
import auth from '@react-native-firebase/auth';
import {createStackNavigator} from '@react-navigation/stack';
import {NavigationContainer} from '@react-navigation/native';
import LoginScreen from './src/screen/LoginScreen';
import OTPScreen from './src/screen/OTPScreen';
import SplashScreen from './src/screen/SplashScreen';
import HomeScreen from './src/screen/HomeScreen';
const RootStack = createStackNavigator();
export default class App extends React.Component {
constructor() {
super();
this.state = {
loading: true,
};
}
/**
* When the App component mounts, we listen for any authentication
* state changes in Firebase.
* Once subscribed, the 'user' parameter will either be null
* (logged out) or an Object (logged in)
*/
async componentDidMount() {
this.authSubscription = auth().onAuthStateChanged((user) => {
console.log(user);
this.setState({
loading: false,
user,
});
});
}
/**
* Don't forget to stop listening for authentication state changes
* when the component unmounts.
*/
componentWillUnmount() {
this.authSubscription();
}
RootStackScreen = () => (
<RootStack.Navigator screenOptions={{headerShown: false, animationEnabled: false}}>
<RootStack.Screen name="SplashScreen" component={SplashScreen}/>
<RootStack.Screen name="Login" component={LoginScreen}/>
<RootStack.Screen name="OTP" component={OTPScreen}/>
<RootStack.Screen name="HomeScreen" component={HomeScreen}/>
</RootStack.Navigator>
);
render() {
return (<NavigationContainer>{this.RootStackScreen()}</NavigationContainer>);
}
}