【发布时间】:2021-12-16 19:26:56
【问题描述】:
发生此问题时,我正在尝试进行电子邮件身份验证
FirebaseError:Firebase:没有创建 Firebase 应用“[DEFAULT]” - 调用 Firebase App.initializeApp() (app/no-app)。
从我读到的东西,人们说这个问题是关于时间问题,但我不确定我的应用程序中这个错误的原因是什么
import React from 'react';
import {ScrollView, StyleSheet, Text, View} from 'react-native';
import {Button, Gap, Input} from '../../components/atoms';
import {Fire} from '../../config';
import {Header} from '../../components/molecules';
import {useForm} from '../../utils';
import {getAuth, createUserWithEmailAndPassword} from 'firebase/auth';
export default function Register() {
const [form, setForm] = useForm({
fullName: '',
bloodType: '',
email: '',
password: '',
});
const onContinue = () => {
console.log(form);
const auth = getAuth();
createUserWithEmailAndPassword(auth, form.email, form.password)
.then(success => {
// Signed in
console.log('register success: ', success);
// ...
})
.catch(error => {
const errorMessage = error.message;
console.log('error register: ', errorMessage);
// ..
});
};
return (
<View>
<Header title="Register User" />
<View style={styles.content}>
<ScrollView showsVerticalScrollIndicator={false}>
<Input
label="Full Name"
value={form.fullName}
onChangeText={value => setForm('fullName', value)}
/>
<Gap height={24} />
<Input
label="Golongan Darah"
value={form.bloodType}
onChangeText={value => setForm('bloodType', value)}
/>
<Gap height={24} />
<Input
label="Email"
value={form.email}
onChangeText={value => setForm('email', value)}
/>
<Gap height={24} />
<Input
label="Password"
value={form.password}
onChangeText={value => setForm('password', value)}
secureTextEntry
/>
<Gap height={40} />
<Button title="Register" onPress={onContinue} />
</ScrollView>
</View>
</View>
);
}
我将我的配置(Fire)放在 getAuth 导入之前,所以我现在有什么遗漏吗?
【问题讨论】:
-
你能分享一下配置文件(从哪里导入 Fire)吗?我建议在同一个文件中初始化身份验证并从那里导出。
-
我把配置ss放在底部@Dharmaraj
标签: javascript android firebase react-native