【发布时间】:2022-08-15 02:12:42
【问题描述】:
我尝试使用 Expo 构建一个电子商务应用程序并做出本机反应,但我遇到了网络错误,设备上的谷歌服务处于活动状态(Android 模拟器和 IOS 真正 iPhone)并且我已连接到我的谷歌帐户。
我还尝试阻止页面重新加载,但没有任何改变。经过一番研究,我所看到的只是我不是唯一一个面临这个错误的人,我没有找到任何有价值的答案,所以我最终来到了这里。
这是我的代码:
const LoginScreen = () => {
const [email, setEmail] = useState(\"\");
const [password, setPassword] = useState(\"\");
const [isSignedIn, setIsSignedIn] = useState(false);
const handleCreateAccount = (e) => {
e.preventDefault();
createUserWithEmailAndPassword(authentification, email, password)
.then((userCredential) => {
console.log(userCredential);
})
.catch((error) => {
console.log(error.message);
});
};
const handleSignIn = (e) => {
e.preventDefault();
signWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
console.log(\"Signed in!\");
const user = userCredential.user;
console.log(user);
})
.catch((error) => {
console.log(error);
Alert.alert(error.message);
});
};
<ScrollView
contentContainerStyle={{
flex: 1,
width: \"100%\",
height: \"100%\",
alignItems: \"center\",
justifyContent: \"center\",
}}
>
<BlurView intensity={100}>
<View style={styles.login}>
<Image
source={{ uri: profilePicture }}
style={styles.profilePicture}
/>
<Text style={{ fontSize: 17, fontWeight: \"400\", color: \"white\" }}>
email
</Text>
<TextInput
onChangeText={(text) => setEmail(text)}
style={styles.input}
placeholder=\"your@email.com\"
keyboardType=\"email-address\"
textContentType=\"emailAddress\"
/>
<Text style={{ fontSize: 17, fontWeight: \"400\", color: \"white\" }}>
mot de passe
</Text>
<TextInput
onChange={(text) => setPassword(text)}
style={styles.input}
placeholder=\"your password\"
secureTextEntry={true}
/>
<Button
onPress={handleSignIn}
title=\"Connexion\"
buttonStyle={{
width: 250,
height: 40,
borderRadius: 10,
backgroundColor: \"#00CFEB90\",
alignItems: \"center\",
justifyContent: \"center\",
marginVertical: 10,
borderColor: \"#fff\",
borderWidth: 2,
}}
type=\"outline\"
titleStyle={{ color: \"white\", fontSize: 17 }}
/>
<Button
onPress={handleCreateAccount}
title=\"Créer un compte\"
buttonStyle={{
width: 250,
height: 40,
borderRadius: 10,
backgroundColor: \"#6792F090\",
alignItems: \"center\",
justifyContent: \"center\",
marginVertical: 10,
borderColor: \"#fff\",
borderWidth: 2,
}}
type=\"outline\"
titleStyle={{ color: \"white\", fontSize: 17 }}
/>
</View>
</BlurView>
</ScrollView>
所以我需要帮助。
-
网页版也有同样的问题,但是,只在 iOS 设备上。它适用于其他设备。
-
我认为是表单/文本输入的代码,因为我在另一个具有不同类型表单的项目中尝试了相同的功能,并且它在 android 模拟器和 Iphone 上工作。
标签: javascript firebase react-native firebase-authentication expo