-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
49 lines (44 loc) · 1.2 KB
/
App.js
File metadata and controls
49 lines (44 loc) · 1.2 KB
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
import React, { Component } from 'react';
import { View, Text } from 'react-native';
import firebase from 'firebase';
import { Header, Button, Spinner } from './src/components/common';
import LoginForm from './src/components/LoginForm';
import Nav from './src/Nav';
class App extends Component {
state = { loggedIn: null };
componentWillMount() {
firebase.initializeApp({
apiKey: 'AIzaSyC43t2UT4IxUZwmJRwgg6GbIZKNRJ_FEoQ',
authDomain: 'piki-partner.firebaseapp.com',
databaseURL: 'https://piki-partner.firebaseio.com',
projectId: 'piki-partner',
storageBucket: 'piki-partner.appspot.com',
messagingSenderId: '305290995933'
});
firebase.auth().onAuthStateChanged(user => {
if (user) {
this.setState({ loggedIn: true });
} else {
this.setState({ loggedIn: false });
}
});
}
renderContent() {
switch (this.state.loggedIn) {
case true:
return <Nav />;
case false:
return <LoginForm />;
default:
return (
<View style={{ flex: 1 }}>
<Spinner size="large" />
</View>
);
}
}
render() {
return this.renderContent();
}
}
export default App;