FirebaseError:函数Query.where()需要一个有效的第三个参数,但它是未定义的

问题描述 投票:1回答:2

this.unsubscribe = this.refAssign.where(‘email’, ‘==’, this.state.user.email ).onSnapshot(this.onCollectionUpdate);

FirebaseError:函数Query.where()需要一个有效的第三个参数,但它是未定义的。

我收到了这条消息。我应该为第三个参数写什么,因为我希望它返回每个“User”,它与“Assign”集合中的电子邮件相同?

javascript reactjs firebase google-cloud-firestore
2个回答
0
投票

在调用此语句之前,请确保this.state.user.email存在。


0
投票

经过多次尝试和错误后,我发现使用“where”子句不可能做到这一点

`componentDidMount() {
    this.unsubscribe1 = this.ref.onSnapshot(this.onCollectionUpdate1);
    this.unsubscribe2 = this.refAssign.where(‘email’, ‘==’, this.state.user.email ).onSnapshot(this.onCollectionUpdate2);
}`

而不是那样,我使用condition ? true : false在渲染中比较它

                        {this.state.user.map(user =>
                          <tr>
                            <td><Link to={`/show/${user.key}`}>{user.email}</Link></td>
                            <td>{user.name}</td>
                            <td>{user.authority}</td>
                            <td>
                            {this.state.assign.map(assign =>
                                <p>{assign.email == user.email ? assign.projNo : null }</p>
                            )}
                            </td>
                          </tr>
                        )}
© www.soinside.com 2019 - 2024. All rights reserved.