“当集合名称错误并试图重定向时,如何从Firebase中删除项目时如何捕获错误”

时间:2019-04-20 15:59:57

标签: react-redux-firebase

我要删除Web应用程序中的帐户,然后仅在没有错误且确实删除了帐户的情况下才重定向到主页。但是,即使firestore中的集合名称不正确,“ react-redux-firebase”库也会解析。

试图在https://github.com/prescottprue/redux-firestore上找到方法firestore.delete()后面的代码,但没有成功

onDeleteClick = () => {
    const { selectedClient, firestore } = this.props;

    let action = window.confirm(
      `Are you sure you want to delete ${selectedClient.firstName} ${
        selectedClient.lastName
      }?`
    );

    if (action) {
      firestore
        .delete({
          collection: "clie1112312123nts",
          doc: selectedClient.id
        })
        .then(() => {        
            console.log("Account Deleted");
            this.props.history.push("/");
        })
        .catch(err => console.log(err));
    }
  };


0 个答案:

没有答案