-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathApp.js
54 lines (47 loc) · 1.37 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
import React, {useState, useEffect} from 'react';
import TasksScreen from './screens/TasksScreen';
import {TouchableWithoutFeedback} from 'react-native';
import AppNavigator from './navigation/navigation';
import Loading from './screens/LoadingScreen';
import firebase from './components/Firebase';
import {decode, encode} from 'base-64';
import {YellowBox} from 'react-native';
import _ from 'lodash';
YellowBox.ignoreWarnings(['Setting a timer']);
const _console = _.clone(console);
console.warn = message => {
if (message.indexOf('Setting a timer') <= -1) {
_console.warn(message);
}
};
global.crypto = require('@firebase/firestore');
global.crypto.getRandomValues = byteArray => {
for (let i = 0; i < byteArray.length; i++) {
byteArray[i] = Math.floor(256 * Math.random());
}
};
if (!global.btoa) {
global.btoa = encode;
}
if (!global.atob) {
global.atob = decode;
}
export default App = () => {
const [user, setUser] = useState(false);
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
firebase.auth().onAuthStateChanged(user => {
setUser(user);
setIsLoading(false);
});
return () => {
console.log('unmount');
clearInterval();
};
}, [user]);
return (
<TouchableWithoutFeedback>
{isLoading ? <Loading /> : user ? <TasksScreen /> : <AppNavigator />}
</TouchableWithoutFeedback>
);
};