Reactjs 更新Firebase上的条目(redux react)

Reactjs 更新Firebase上的条目(redux react),reactjs,firebase,redux,google-cloud-firestore,Reactjs,Firebase,Redux,Google Cloud Firestore,我被一个项目困住了,老实说,我不知道如何解决它(在你判断之前,我是个新手) 这是我的代码: class EditProfile extends Component { state = { företagsnamn: '', organisationsnummer: '', }; handleChange = e => { this.setState({ [e.target.id]: e.target.value }); };

我被一个项目困住了,老实说,我不知道如何解决它(在你判断之前,我是个新手)

这是我的代码:

class EditProfile extends Component {
  state = {
    företagsnamn: '',
    organisationsnummer: '',
  };

  handleChange = e => {
    this.setState({
      [e.target.id]: e.target.value
    });
  };
  handleSubmit = e => {
    e.preventDefault();
    // console.log(this.state);
    this.props.editProfile(this.state);
    this.props.history.push("/dash");
  };
  render() {
    const { auth, profile } = this.props;
    if (auth.isEmpty) return <Redirect to="/dash" />;
    return (
      <div >        
        <form className="white" onSubmit={this.handleSubmit}>
          <div className="row">
            <div className="col xl6 l6 m6 s12">
 <label>Foretagsnamn:</label>
          <input
            type="text"
            disabled
            placeholder={profile.foretagsnamn}
            id="foretagsnamn"
            onChange={this.handleChange}
            />
            </div>
            <div className="col xl6 l6 m6 s12">
            <label>organisationsnummer:</label>
          <input
            type="number"
            placeholder={profile.organisationsnummer}
            id="organisationsnummer"
            onChange={this.onChange}
            />
            </div>
            </div>


<div className="input-field">
          <button className="btn orange lighten-1" style={{width:'100%'}} >Submit</button>
          { }
        </div>
          </form>
</div>
}}


const mapStateToProps = state => {
  return {
    auth: state.firebase.auth,
    profile: state.firebase.profile
  };
};

const mapDispatchToProps = dispatch => {
  return {
    editProfile: profil => dispatch(editProfile(profil))
  };
};

export default connect(
  mapStateToProps,
  mapDispatchToProps
)(EditProfile);

这是减速器

 const editProfileReducer = (state = initState, action) => {
    switch (action.type) {
      case "EDITPROFILE_ERROR":
        return {
          ...state,
        editError: action.error
    };
    case "EDITPROFILE_SUCCESS":
        return {
          ...state,
          user:action.user

    };
      default:
      return state;
    }
  }

  export default editProfileReducer;

但是,当我按下“提交”按钮时,会显示此错误:

FirebaseError:函数CollectionReference.doc()要求其第一个参数的类型为非空字符串,但它是:未定义

PS:已解决。行动是错误的。我更改了const profile=getState().firebase.auth.`````**而不是profile**


如果有人需要,可以保持打开状态。

您可以在{firestore.collection('users').doc(profile.uid)中更改.add to.set。添加({…profil}),如果仍然存在错误,请给出屏幕截图?×FirebaseError:Function CollectionReference.doc()要求其第一个参数的类型为非空字符串,但是它是:UnfinedGeves相同的错误。设置相同的错误。在创建{profile}一行之后,您可以控制台日志吗?显示数据库中已经存在的条目。您可以在{firestore.collection('users').doc(profile.uid)中更改.add to.set。添加({…profile})}如果仍然存在错误,请给出一个屏幕截图?×FirebaseError:函数CollectionReference.doc()要求其第一个参数的类型为非空字符串,但它是:UnfinedGeves相同的错误。设置相同的错误。是否可以在创建{profile}一行后对其进行控制台日志记录?显示数据库中已经存在的条目
 const editProfileReducer = (state = initState, action) => {
    switch (action.type) {
      case "EDITPROFILE_ERROR":
        return {
          ...state,
        editError: action.error
    };
    case "EDITPROFILE_SUCCESS":
        return {
          ...state,
          user:action.user

    };
      default:
      return state;
    }
  }

  export default editProfileReducer;