Gan*_*nzo 4 javascript firebase react-native firebase-authentication expo
我尝试使用 Expo 构建一个电子商务应用程序并做出本机反应,但我遇到网络错误,谷歌服务在设备上处于活动状态(Android 模拟器和 IOS 真实 iPhone),并且我已连接到我的 Google 帐户。
\n我也尝试阻止页面重新加载,但没有任何改变。经过一番研究后,我发现我并不是唯一一个面临此错误的人,我没有找到任何有价值的答案,所以我最终来到这里。
\n这是我的代码:
\nconst LoginScreen = () => {\n const [email, setEmail] = useState("");\n const [password, setPassword] = useState("");\n const [isSignedIn, setIsSignedIn] = useState(false);\n\n const handleCreateAccount = (e) => {\n e.preventDefault();\n createUserWithEmailAndPassword(authentification, email, password)\n .then((userCredential) => {\n console.log(userCredential);\n })\n .catch((error) => {\n console.log(error.message);\n });\n };\n\n const handleSignIn = (e) => {\n e.preventDefault();\n signWithEmailAndPassword(auth, email, password)\n .then((userCredential) => {\n console.log("Signed in!");\n const user = userCredential.user;\n console.log(user);\n })\n .catch((error) => {\n console.log(error);\n Alert.alert(error.message);\n });\n };\n\n <ScrollView\n contentContainerStyle={{\n flex: 1,\n width: "100%",\n height: "100%",\n alignItems: "center",\n justifyContent: "center",\n }}\n >\n <BlurView intensity={100}>\n <View style={styles.login}>\n <Image\n source={{ uri: profilePicture }}\n style={styles.profilePicture}\n />\n <Text style={{ fontSize: 17, fontWeight: "400", color: "white" }}>\n email\n </Text>\n <TextInput\n onChangeText={(text) => setEmail(text)}\n style={styles.input}\n placeholder="your@email.com"\n keyboardType="email-address"\n textContentType="emailAddress"\n />\n <Text style={{ fontSize: 17, fontWeight: "400", color: "white" }}>\n mot de passe\n </Text>\n <TextInput\n onChange={(text) => setPassword(text)}\n style={styles.input}\n placeholder="your password"\n secureTextEntry={true}\n />\n <Button\n onPress={handleSignIn}\n title="Connexion"\n buttonStyle={{\n width: 250,\n height: 40,\n borderRadius: 10,\n backgroundColor: "#00CFEB90",\n alignItems: "center",\n justifyContent: "center",\n marginVertical: 10,\n borderColor: "#fff",\n borderWidth: 2,\n }}\n type="outline"\n titleStyle={{ color: "white", fontSize: 17 }}\n />\n <Button\n onPress={handleCreateAccount}\n title="Cr\xc3\xa9er un compte"\n buttonStyle={{\n width: 250,\n height: 40,\n borderRadius: 10,\n backgroundColor: "#6792F090",\n alignItems: "center",\n justifyContent: "center",\n marginVertical: 10,\n borderColor: "#fff",\n borderWidth: 2,\n }}\n type="outline"\n titleStyle={{ color: "white", fontSize: 17 }}\n />\n </View>\n </BlurView>\n </ScrollView>\n
Run Code Online (Sandbox Code Playgroud)\n所以我需要帮助。
\nRen*_*aud 12
万一它对某人有帮助。
我遇到了同样的问题并浪费了很多时间进行调查。事实证明,就我而言,这只是 firebase 层中的 DNS 问题。
localhost
模拟器的 URL 中的内容未解析。我用它替换了它127.0.0.1
并且工作正常。
该auth/network-request-failed
错误可能特别具有误导性,因为它似乎是由于多种不同的原因而出现的。我见过它有以下任一情况:
如果上述方法均不起作用,请提供您收到的完整错误(检查 React 错误和设备级错误日志)。
归档时间: |
|
查看次数: |
15283 次 |
最近记录: |