Having trouble with an error while following a tutorial on YouTube. I've searched for solutions but all the tutorials focus on Google sign-in, which I don't need.
If anyone can offer help, Thank You Very Much.
P.S. I'm still new to Firebase.
App.tsx
import React from 'react'
import { StatusBar } from 'expo-status-bar';
import { Alert, StyleSheet, View } from 'react-native';
import { getAuth, createUserWithEmailAndPassword, isSignInWithEmailLink, signInWithEmailAndPassword } from 'firebase/auth'
import {initializeApp} from 'firebase/app'
import { firebaseConfig } from './src/config/firebase';
import { Input, Button, Div, Text } from 'react-native-magnus';
import { NavigationContainer, useNavigation } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
function HomeScreen(){
return(
<Div flex={1} justifyContent='center' alignSelf='center'>
<Text>Hallo</Text>
</Div>
)
}
function LoginScreen(){
const [email, setEmail] = React.useState('')
const [password, setPassword] = React.useState('')
const app = initializeApp(firebaseConfig)
const auth = getAuth(app)
const nav = useNavigation()
const handleCreateAccount = () => {
createUserWithEmailAndPassword(auth, email,password)
.then((userCredential) => {
console.log("Account Created")
const user = userCredential.user
console.log(user)
})
.catch((err) => {
console.log(err)
alert(err.message)
})
}
const handleSignIn = () => {
signInWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
console.log("Signed In!")
const user = userCredential.user
console.log(user)
nav.navigate("Home")
})
.catch((err) => {
console.log(err)
})
}
return(
<View style={styles.container}>
<Div w={300}>
<Input value={email} onChange={(val:any) => setEmail(val) } placeholder='Email..' />
<Input value={password} onChange={(val:any) => setPassword(val)} placeholder='Password..' mt={10} />
</Div>
<Div justifyContent='center'>
<Button onPress={handleSignIn} w={100} mt={10}>
Sign-In
</Button>
<Button onPress={handleCreateAccount} w={100} mt={10}>
Register
</Button>
</Div>
<StatusBar style="auto" />
</View>
)
}
const Stack = createNativeStackNavigator()
export default function App() {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Login" component={LoginScreen} options={{headerShown: false}} />
<Stack.Screen name="Home" component={HomeScreen} />
</Stack.Navigator>
</NavigationContainer>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
Encountering an error when trying to register because login isn't working.