reactjs - 保存一些状态值到 Firestore 反应
问题描述
我想将状态值的一些细节保存到 Firestore。我怎样才能做到这一点。?
状态细节
state = {
loading: false,
sp_name: '',
sp_Phone: '',
sp_Role: '',
sp_Location: '',
sp_Service: '',
sp_country: '',
sp_message: '',
sp_License: ''
}
我不想将加载状态保存到 Firestore。
处理提交事件。
handleSubmit = (e) => {
e.preventDefault();
this.setState({ loading: true })
let uid = this.props.auth.uid;
this.props.UpdateUser(uid, this.state)
this.setState({ loading: false })
toast("Registered Successfully.!", { type: toast.TYPE.INFO, autoClose: 5000 });
}
解决方案
handleSubmit = (e) => {
e.preventDefault();
this.setState({ loading: true })
const stateObj = this.state;
delete stateObj['loading'];
let uid = this.props.auth.uid;
this.props.UpdateUser(uid, stateObj)
this.setState({ loading: false })
toast("Registered Successfully.!", { type: toast.TYPE.INFO, autoClose: 5000 });
}
推荐阅读
- java - 使用 ModelMapper 映射抽象类型的字段
- python - 我正在尝试使用 Python 获取邮件的接收时间,但每次都会出现以下错误
- jenkins - Jenkins 使用带有环境声明管道的 docker 代理
- ios - 如何为不同的iOS版本显示不同的静态单元格?(静态`UITableView`)
- java - 具有 C# 中默认方法的功能接口
- android - 我想从下面的 json 响应中创建一个 sub_activity_codes 对象列表
- version-control - 在 GitLab 中安全地存储秘密和凭据
- php - Laravel 403 Forbidden:您无权访问此文档
- html - Box-shadow 不适用于我的图像元素
- vba - 使用 VBA 将字符串分成“名称”和“数字”两部分