用户名缺少与firebase的反应js

时间:2018-09-12 21:49:40

标签: javascript reactjs firebase google-cloud-firestore

我在将userId发送到Firebase上的集合时遇到麻烦,唯一发送的是“ userId:未定义”。我应该在字段userId上输入什么?

class AddTopic extends Component {
 state = {
 userName: "",
 topic: "",
 date: "",
 userId: `${this.userId}`
};

onSubmit = e => {
 e.preventDefault();

 const newTopic = this.state;

 const { firestore, history } = this.props;

 firestore
   .add({ collection: "topics" }, newTopic)
   .then(() => history.push("/"));
 };

0 个答案:

没有答案