forked from ackothalawala/Mini-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
40 lines (30 loc) · 941 Bytes
/
App.tsx
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
// App.js
import { createStackNavigator } from '@react-navigation/stack';
import { decode, encode } from 'base-64';
import 'firebase/auth';
import 'firebase/firestore';
import 'react-native-gesture-handler';
import Navigation from './Navigation/navigation';
import React, { useEffect, useState } from 'react';
import { getAuthToken } from './src/authStorage/authStorage';
if (!global.btoa) { global.btoa = encode; }
if (!global.atob) { global.atob = decode; }
const Stack = createStackNavigator();
export default function App() {
const [isLoading, setIsLoading] = useState(true);
const [userToken, setUserToken] = useState(null);
useEffect(() => {
const bootstrapAsync = async () => {
const token = await getAuthToken();
setUserToken(token);
setIsLoading(false);
};
bootstrapAsync();
}, []);
if (isLoading) {
return null;
}
return (
<Navigation userToken={userToken} />
);
}