I 반응 네이티브에 사용자가 로그인 할 수있는 간단한 예를 다음입니다 "정의되지 않은은 (평가 '_this2.onLoginSuccess.bind') 객체가 아닌". 나는 코드가반작용 - 네이티브 오류
를 처리하기 위해 다음과 같은 추가 된onButtonPress() {
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
});
}
하지만 난 반응 네이티브 매우 새로운 오전 "undefined is not an object (evaluating '_this2.onLoginSuccess.bind')
"
오류 때문에 설명해주십시오.
내 생각 엔'onButtonPress'가 이벤트 핸들러로 사용하고 있기 때문에 아마 제대로 바인딩되지 않았을 것이다. – Li357