Skip to content

Commit 7117916

Browse files
committed
fix: auto navigate to Home
1 parent dff7301 commit 7117916

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

mobile/src/screens/LoginScreen.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from 'react';
1+
import { useState, useEffect } from 'react';
22
import { View, Text, TextInput, TouchableOpacity, StyleSheet, Alert, KeyboardAvoidingView, Platform, ScrollView, Image } from 'react-native';
33
import { SafeAreaView } from 'react-native-safe-area-context';
44
import AsyncStorage from '@react-native-async-storage/async-storage';
@@ -24,6 +24,14 @@ export default function LoginScreen({ navigation }) {
2424
const [form, setForm] = useState({ name: '', email: '', password: '', confirm: '' });
2525
const { login } = useApp();
2626

27+
useEffect(() => {
28+
const checkUser = async () => {
29+
const saved = await AsyncStorage.getItem('zappify_user');
30+
if (saved) navigation.replace('Home');
31+
};
32+
checkUser();
33+
}, []);
34+
2735
const handleGoogleSignIn = async () => {
2836
if (!GoogleSignin) {
2937
Alert.alert('Not Available', 'Google Sign In is only available in the production build.');

0 commit comments

Comments
 (0)