【发布时间】:2018-12-08 14:39:42
【问题描述】:
我想将所有 documents 存储在 firebase 中。如果有超过 0 个文档,则渲染 1,否则打印 no doc found 但这会给我错误:
render() {
firebase
.firestore()
.collection("users")
.doc(localStorage.getItem("ph"))
.collection("chat")
.get()
.then(d => {
this.dt = d.docs.length;
if (this.dt > 0) {
return <div>1</div>;
} else {
return (
<div>
<div className="app-noFoundArea">
<img src={noFound} />
</div>
<div className="app-noFound-title">
<p>
No chat found. Try create using{" "}
<button className="app-add-icon app-nofound">
<i className="material-icons">add</i>
</button>
</p>
</div>
</div>
);
}
})
.catch(e => {});
}
【问题讨论】:
标签: javascript reactjs