-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuthLoading.js
More file actions
28 lines (24 loc) · 855 Bytes
/
AuthLoading.js
File metadata and controls
28 lines (24 loc) · 855 Bytes
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
import React, {useEffect} from 'react';
import {ActivityIndicator, View} from 'react-native';
import {useNavigation} from '@react-navigation/native';
import {getAuth, onAuthStateChanged} from "firebase/auth";
import tw from './tailwind';
const AuthLoading = () => {
const navigation = useNavigation();
const auth = getAuth();
useEffect(() => {
return onAuthStateChanged(auth, (user) => {
if (user) {
navigation.reset({index: 0, routes: [{name: 'Home'}]});
} else {
navigation.reset({index: 0, routes: [{name: 'Login'}]});
}
});
}, [navigation]);
return (
<View style={tw`flex-1 justify-center items-center bg-slate-900`}>
<ActivityIndicator size="large" color="#7C3AED" />
</View>
);
};
export default AuthLoading;