import React from "react";
import { ActivityIndicator, View } from "react-native";
import { globalStyles } from "../constants/styles";
import { router } from "expo-router";
import { Auth } from "aws-amplify";
export default class AuthLoadingScreen extends React.Component {
state = {
userToken: null,
};
async componentDidMount() {
await this.loadApp();
}
// Get the logged in users and remember them
loadApp = async () => {
await Auth.currentAuthenticatedUser()
.then((user) => {
this.setState({
userToken: user.signInUserSession.accessToken.jwtToken,
});
})
.catch((err) => console.log(err));
// this.props.navigation.navigate(this.state.userToken ? "App" : "Auth");
// router.replace(this.state.userToken ? "/home" : "/root");
if(this.state.userToken){
router.replace('/home');}
};
render() {
console.log("user token: ", this.state.userToken);
return (
<View style={[globalStyles.container, {maxHeight:0}]}>
<ActivityIndicator size="large" color="#fff" />
</View>
);
}
}