-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
49 lines (40 loc) · 1.2 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
/* eslint no-undef: "off" */
/* eslint global-require: "off" */
import React, { Component } from 'react';
import { Provider } from 'react-redux';
import firebase from '@firebase/app';
import '@firebase/auth';
import Spinner from 'react-native-loading-spinner-overlay';
import { Root } from 'native-base';
import Router from './js/Router';
import Store from './js/configureStore';
import { SIGN_IN_SUCCESS } from './js/Auth/AuthActions';
import firebaseConfig from './js/firebase.json';
export default class App extends Component {
constructor(props) {
super(props);
this.state = { loaded: false };
}
async componentWillMount() {
await Expo.Font.loadAsync({
Roboto: require('native-base/Fonts/Roboto.ttf'),
Roboto_medium: require('native-base/Fonts/Roboto_medium.ttf'),
});
firebase.initializeApp(firebaseConfig);
firebase.auth().onAuthStateChanged((user) => {
this.setState({ loaded: true });
if (user) {
Store.dispatch({ type: SIGN_IN_SUCCESS, payload: user });
}
});
}
render() {
return (
<Provider store={Store}>
<Root>
{this.state.loaded ? <Router /> : <Spinner />}
</Root>
</Provider>
);
}
}