-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
47 lines (42 loc) · 1.12 KB
/
App.js
File metadata and controls
47 lines (42 loc) · 1.12 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
import React from 'react';
import { View } from 'react-native';
import firebase from 'firebase';
import {Header, Spinner} from './app/components/common';
import LoginForm from './app/components/LoginForm';
import Profile from './app/components/Profile';
export default class App extends React.Component {
state = { loggedIn: false }
constructor(props) {
super(props);
firebase.initializeApp({
apiKey: 'Get this from Firebase Dashboard',
authDomain: 'Get this from Firebase Dashboard',
databaseURL: 'Get this from Firebase Dashboard',
projectId: 'Get this from Firebase Dashboard',
storageBucket: 'Get this from Firebase Dashboard',
messagingSenderId: 'Get this from Firebase Dashboard'
});
firebase.auth().onAuthStateChanged((user) => {
if (user) {
this.setState({ loggedIn: true });
} else {
this.setState({ loggedIn: false });
}
});
}
renderForm(){
if(this.state.loggedIn){
return <Profile />;
}else{
return <LoginForm/>;
}
}
render() {
return (
<View >
<Header headerText="Auth" />
{this.renderForm()}
</View>
);
}
}