verfolge ich ein einfaches Beispiel in reagieren-native Benutzer eingeloggt sein. Ich habe folgenden Code, dassReact-Native Error „nicht definiert ist kein Objekt (Bewertung‚_this2.onLoginSuccess.bind‘)“
zu handhabenonButtonPress() {
const { email, password } = this.state;
this.setState({ error: '', loading: true });
firebase.auth().signInWithEmailAndPassword(email, password)
.then(this.onLoginSuccess.bind(this))
.catch(() => {
firebase.auth().createUserWithEmailAndPassword(email, password)
.then(this.onLoginSucess.bind(this))
.catch(this.onLoginFail.bind(this));
});
}
onLoginSuccess() {
this.setState({
email: '',
password: '',
loading: false,
error: ''
});
}
onLoginFail() {
this.setState({
error: 'Authentication Failed',
loading: false
});
}
aber ich bekomme Fehler "undefined is not an object (evaluating '_this2.onLoginSuccess.bind')
"
ich bin sehr neu zu reagieren-native, also bitte erklären.
Meine Vermutung ist, dass 'onButtonPress' nicht korrekt gebunden ist, wahrscheinlich weil Sie es als Event-Handler verwenden. – Li357