【发布时间】:2023-03-07 20:44:01
【问题描述】:
您好,我实际上是一名初学者,正在从事我的 React Native 项目,我也在 React Native 中使用 Firebase。我遇到了一个问题,就像我在标题中所说的那样,Firebase 中的实时数据库完全像这样获取“姓名”、“姓氏”和“生日”数据;
当我单击“更新”时,我希望 Firebase 仅将我的数据作为一个完整的字符串作为“名称”获取一次,而不是像“N”那样逐个字母然后“Na”......等等(这种情况适用也适用于“姓名”、“姓氏”和“生日”数据。)。
这是我的代码:
class Profile extends Component {
onChangeName(profile) {
this.props.updateProfile(profile);
}
onChangeSurname(profile) {
this.props.updateProfile(profile);
}
updateProfile() {
this.props.updateProfile(this.props.profile);
}
render() {
return (
<View>
<Profiletext
placeholder="Name..."
onChangeText={this.onChangeName.bind(this)}
/>
<Profiletext
placeholder="Surname..."
onChangeText={this.onChangeSurname.bind(this)}
/>
<Profiletext
placeholder="Birthday..."
onChangeText={this.onChangeSurname.bind(this)}
/>
<MyButton
spinner={false}
title="UPDATE"
onPress={this.updateProfile.bind(this)}
color="#E87B79"
/>
</View>
);
}
}
const mapStateToProps = state => {
const {profile} = state.profileForm;
return {
profile,
};
};
export default connect(
mapStateToProps,
{
changeProfile,
updateProfile,
},
)(Profile);
【问题讨论】:
-
您能否编辑您的问题以显示您当前如何从数据库中加载数据?
标签: javascript firebase react-native firebase-realtime-database