-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathApp.js
51 lines (46 loc) · 1.43 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
import firebase from 'firebase';
import React from 'react';
import {AppLoading, Font} from "expo";
import Routes from './src/Routes';
import {Root} from 'native-base';
import store from './src/store/configureStore';
import config from './firebase.config';
import {SIGN_IN_SUCCESS} from './src/store/actions/auth.actions';
import {setProfileLocation} from './src/store/actions/profile.actions';
// ignore firebase warn
console.ignoredYellowBox = [
'Setting a timer'
];
export default class App extends React.Component {
constructor() {
super();
this.state = {
loading: true
}
}
componentDidMount() {
//firebase
firebase.initializeApp(config);
firebase.auth().onAuthStateChanged(async (user) => {
if (user !== null) {
await setProfileLocation({uid: user.uid})(store.dispatch);
store.dispatch({type: SIGN_IN_SUCCESS, payload: user});
}
});
}
async componentWillMount() {
await Font.loadAsync({
Roboto: require("native-base/Fonts/Roboto.ttf"),
Roboto_medium: require("native-base/Fonts/Roboto_medium.ttf"),
Ionicons: require("native-base/Fonts/Ionicons.ttf")
});
this.setState({loading: false});
}
render() {
return (
<Root>
{this.state.loading ? <AppLoading/> : <Routes/>}
</Root>
);
}
}