Я хочу отправить значения TextInput
, нажав кнопку. Но есть ошибка. Как мне это исправить? Ниже приводится содержание ошибки.
Undefined не является объектом (оценка 'class.state.nickname')
Можете ли вы сказать мне, в чем проблема?
constructor(props) {
super(props);
this.state = {
uid: firebase.auth().currentUser.uid,
nickname: null,
introduction: null
};
this.successEditProfile = this.successEditProfile.bind(this);
}
static navigationOptions = () => ({
headerTitle: (
<View style={styles.logoView}>
<Text>프로필 편집</Text>
</View>
),
headerRight: (
<View style={styles.headerView}>
<TouchableOpacity
onPress={() =>
this.successEditProfile(
this.state.nickname,
this.state.introduction
)
}
>
<Text style={styles.headerIcon}>완료</Text>
</TouchableOpacity>
</View>
)
});
successEditProfile = (nickname, introduction) => {
if (nickname != null && introduction != null) {
try {
firebase
.database()
.ref("users/" + this.state.uid)
.update({
nickname: this.state.nickname,
introduction: this.state.introduction
});
} catch (error) {
console.log(error.toString(error));
}
}
};