Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6290

[FirebaseError: Firebase: Error (auth/network-request-failed)

$
0
0

So i have an error following tutorial on youtube, already try finding on youtube how to fix it but the tutorial show google sign-in but i don't use that function

if anyone can help Thank You Very Much

P.S Still learning firebase so im new here

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',  },});

the error is when i try to register, because u can't login


Viewing all articles
Browse latest Browse all 6290

Trending Articles