我有以下内容:
import Firebase from '../Firebase/firebase';
function SignIn() {
const[email, setEmail] = useState('');
const[password, setPassword] = useState('');
async function onSignIn() {
try {
await Firebase.doSignInWithEmailAndPassword(email, password);
this.props.history.push('/start');
} catch(error) {
alert(error);
}
}
这是我的Firebase课:
import app from 'firebase/app';
import 'firebase/auth';
// Your web app's Firebase configuration
class Firebase {
constructor() {
app.initializeApp(config);
this.auth = app.auth;
}
doSignInWithEmailAndPassword = (email, password) => {
return this.auth.signInWithEmailAndPassword(email, password);
}
logout() {
return this.auth.signOut();
}
async register(name, email, password) {
await this.auth.createUserWithEmailAndPassword(email, password);
return this.auth.currentUser.updateProfile({
displayName: name
});
}
}
export default new Firebase();
错误:
TypeError:this.auth.signInWithEmailAndPassword不是函数
我不明白为什么要得到这个?
答案 0 :(得分:1)
您尝试过吗?
this.auth = app.auth()