-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
43 lines (40 loc) · 1.18 KB
/
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
41
42
43
import React, { useState, useEffect } from "react";
import firebase from "./firebase";
import Landing from "./components/auth/Landing";
import { StyleSheet, View, Text } from "react-native";
import reducer, { initialState } from "./StateHooks/reducer.";
import { StateProvider } from "./StateHooks/StateProvider";
import Main from "./components/Main";
const App = () => {
const [loaded, setLoaded] = useState<boolean>();
const [id, setId] = useState<string>();
const [loggedIn, setLoggedIn] = useState<boolean>();
useEffect(() => {
firebase.auth().onAuthStateChanged((user) => {
if (!user) {
setLoggedIn(false);
setLoaded(true);
} else {
setLoggedIn(true);
setLoaded(true);
setId(user.uid);
console.log(user.email);
console.log(user.uid);
}
});
}, []);
return (
<StateProvider initialState={initialState} reducer={reducer}>
<View>
{id && <Main data={id}/>}
{loggedIn ? (
<Text>{`This is ${JSON.stringify(loggedIn)}`}</Text>
) : (
<Landing />
)}
</View>
</StateProvider>
);
};
export default App;
const styles = StyleSheet.create({});