因此,我有一个错误,以下教程在YouTube上,已经尝试在YouTube上找到如何解决它,但教程显示谷歌登录,但我不使用该功能
如果有人能帮忙的话非常感谢
还在学习火力,所以我是新来的
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',
},
});
错误是当我试图注册,因为你不能登录
1条答案
按热度按时间vfh0ocws1#
当您的计算机没有正确连接到
internet
时,通常会抛出此类错误。尝试检查设备上的
internet connectivity
,然后重试!