我在将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("/"));
};