私が作成した反応コンポーネントには、次のコンストラクターと関数があります。
constructor() {
super()
this.state = {
error: false
}
}
handleSubmit(e) {
e.preventDefault()
const email = this.refs.email.value
const password = this.refs.password.value
const self = this
firebase.auth().signInWithEmailAndPassword(email, password).then(
function(result) {
const location = self.props.location
if (location.state && location.state.nextPathname) {
self.context.router.replace(location.state.nextPathname)
} else {
self.context.router.replace("/home")
}
// User signed in!
console.log("User signed in!")
}).catch(function(error) {
this.setState({error: error}) // Error points to this line
})
}
コンソールに次のエラーが表示され続けます。
キャッチされていない TypeError: 未定義のプロパティ 'setState' を読み取ることができません
誰でも私が問題を特定するのを助けることができますか?