-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathApp.tsx
More file actions
39 lines (35 loc) · 1.04 KB
/
App.tsx
File metadata and controls
39 lines (35 loc) · 1.04 KB
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
import { StatusBar } from "expo-status-bar";
import { SafeAreaView } from "react-native-safe-area-context";
import Main from "./src/navigation/Main";
import { ActivityIndicator, View } from "react-native";
import { useEffect, useState } from "react";
import { AuthChanged } from "./src/utils/firebaseMethods";
import { User } from "@firebase/auth";
export default function App() {
const [user, setUser] = useState<User | null>(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
const unsubscribe = AuthChanged((user) => {
if (user) {
setUser(user);
} else {
setUser(null);
}
setLoading(false);
});
return () => unsubscribe();
}, []);
if (loading) {
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<ActivityIndicator size={"large"} color={"green"} />
</View>
);
}
return (
<SafeAreaView style={{ flex: 1 }}>
<Main user={user} />
<StatusBar backgroundColor="#A4B465" />
</SafeAreaView>
);
}