I'm doing user login checks using the AuthProvider method. When I enter the correct information on the login screen, I encounter an error as follows.
Login Screen
import React, { useState, useContext } from "react";
import * as Yup from "yup";
import { Formik } from "formik";
import auth from '@react-native-firebase/auth';
import LinearGradient from 'react-native-linear-gradient';
import Color from 'react-native-material-color';
import { AuthContext } from '../../Navigation/AuthProvider';
import {
Text,
View,
StyleSheet,
SafeAreaView,
Image,
TextInput,
Button,
ScrollView,
TouchableOpacity
} from 'react-native';
export default login = ({navigation})=>{
const { useContext } = React;
const {login} = useContext(AuthContext);
const signInvalidationSchema =Yup.object().shape({
email:Yup
.string()
.required('boş geçilemez')
.email('geçerli bir email adresi yaziniz'),
password:Yup
.string()
.required('boş geçilemez').min(6,({min})=>'sifre en az '+ min +'karakter olmalıdır!')
})
/*function _handleSubmit (values){
auth()
.signInWithEmailAndPassword(values.email, values.password)
.then(() => {
alert('basarılı giriş')
})
.catch(error => {
if (error.code === 'auth/wrong-password') {
alert('wrong pass')
return;
}
if (error.code === 'auth/user-not-found') {
alert('User Not Found');
return;
}
console.error(error);
});
this.props.navigation.navigate('profile');
}*/
return (
<SafeAreaView style={styles.container}>
<ScrollView>
<View style={styles.top}>
<Image
style={{
width: 150,
height: 200,
resizeMode: 'contain'
}}
source={
require('../../image/logo.png')
}
/>
<Text style={styles.textLogo}>AGER FORUM</Text>
</View>
<Formik
initialValues={{
email: '',
password: ''
}}
onSubmit={(values)=>login(values.email,values.password)}
validationSchema={signInvalidationSchema}
>
{
({
values,
handleSubmit,
isValid,
isSubmitting,
errors,
handleBlur,
handleChange
}) => (
<View style={styles.mid}>
<View style={styles.box}>
<View style={styles.textBox}>
<Text style={styles.textMid}>E-mail</Text>
</View>
<View style={styles.inputView}>
<LinearGradient
colors={['#840ec1', '#a643d9', '#d743d9', '#be1dc0', '#a00ba2', '#8a04a6']}
start={{ x: 0.0, y: 1.0 }} end={{ x: 1.0, y: 1.0 }}
style={styles.grediant}
>
<TextInput
values={values.email}
onChangeText={handleChange('email')}
onBlur={handleBlur('email')}
placeholder={"Email"}
placeholderTextColor={"#302000"}
style={styles.input}
keyboardType="email-address"
/>
</LinearGradient>
{(errors.email) && <Text style={styles.error}>{errors.email}</Text>}
</View>
{/*(errors.email) && <Text styles={styles.error}>{errors.email}</Text>*/}
</View>
<View style={styles.box}>
<View style={styles.textBox}>
<Text style={styles.textMid}>Şifre</Text>
</View>
<View style={styles.inputView}>
<LinearGradient
colors={['#840ec1', '#a643d9', '#d743d9', '#be1dc0', '#a00ba2', '#8a04a6']}
start={{ x: 0.0, y: 1.0 }} end={{ x: 1.0, y: 1.0 }}
style={styles.grediant}
>
<TextInput
values={values.password}
onChangeText={handleChange('password')}
onBlur={handleBlur('password')}
placeholder={"Password"}
placeholderTextColor={"#302000"}
style={styles.input}
secureTextEntry={true}
/>
</LinearGradient>
{(errors.password) && <Text style={styles.error}>{errors.password}</Text>}
</View>
</View>
<TouchableOpacity
disabled={!isValid }
onPress={handleSubmit}
style={styles.button}
>
<Text style={styles.button_text}>Sign in My Account</Text>
</TouchableOpacity>
<View style={styles.kayitText}>
<TouchableOpacity
onPress={() =>navigation.navigate('Register')}
>
<Text style={{ color: 'white', fontSize: 14, fontWeight: 'bold' }}>Kayit Ol</Text>
</TouchableOpacity>
</View>
</View>
)
}
</Formik>
<View style={styles.bot}>
</View>
</ScrollView>
</SafeAreaView>
);
}
AuthProvider Code
import { View, Text } from 'react-native'
import React,{useState,useEffect,createContext} from 'react'
import auth from '@react-native-firebase/auth'
export const AuthContext = createContext({});
export const AuthProvider = ({children}) => {
console.log('first');
const [user, setUser] = useState(null);
return (
<AuthContext.Provider
value={{
user,
setUser,
login:async(email,password)=>{
try {
await auth().signInWithEmailAndPassword(email,password)
.then(async result =>{
if(!result.user.emailVerified){
result.user.sendEmailVerification();
alert('Lütfen emailinize gelen maili onaylayınız')
}
})
} catch (error) {
console.log('errorlogin',error),
console.log('user',user)
}
},
register:async(email,password,name)=>{
try {
await auth().createUserWithEmailAndPassword(email,password)
.then(async result =>{
result.user.updateProfile({
displayName:name
})
result.user.sendEmailVerification();
alert('Kayıt işlemi bittikten sonra lütfen emailinize gelen maili onaylayınız')
})
} catch (error) {
console.log(error),
console.log('user',user)
}
},
resetPass:async(email)=>{
try {
await auth().sendPasswordResetEmail(email);
alert('sifre sıfırlama kodunuz emaile gönderilmiştir')
} catch (error) {
console.log(error)
}
},
signOut:async()=>{
try {
await auth().signOut();
alert('çıkış başarılı')
} catch (error) {
console.log(error)
}
},
}}
>{children}
</AuthContext.Provider>
)
}
Fault
I know this is just a warning but although everything looks correct it doesn't complete successfully and I don't get an error either
