Reactjs orderBy查询不工作,因此尝试区分手动但无法使其工作

Reactjs orderBy查询不工作,因此尝试区分手动但无法使其工作,reactjs,react-native,foreach,google-cloud-firestore,Reactjs,React Native,Foreach,Google Cloud Firestore,我想创建一个数组,列出在我的查询中出现的独特城市。 所以我喜欢: this.dbRef.where('Destination', '==', this.state.delegation) .orderBy("Location", "desc") .get() // .where('Gender', '==', 'male') .then(querySnapshot=> .. 但是它不能与or

我想创建一个数组,列出在我的查询中出现的独特城市。 所以我喜欢:

 this.dbRef.where('Destination', '==', this.state.delegation)
                .orderBy("Location", "desc")
                .get() // .where('Gender', '==', 'male')
                .then(querySnapshot=> ..
但是它不能与orderBy一起使用。。任何其他的查询都有效——我在谷歌上搜索了一下,找不到正确的答案

因此,我试图通过让城市的名字与众不同来恢复它

这是我的代码:

    const cityArr = [];
        this.dbRef
            .where('Destination', '==', this.state.delegation)
            .get() 
            .then(querySnapshot=> {
                querySnapshot.forEach(doc => {
                        cityArr.push({
                            City: doc.data().Location,
                        })
                    console.log('City array:! ',cityArr)  // <~~~~ working
                });
            })

const cityar=[];
这个是.dbRef
.where('Destination','=',this.state.delegation)
.get()
.然后(querySnapshot=>{
querySnapshot.forEach(doc=>{
城市推({
城市:doc.data().位置,
})
console.log('City数组:!',cityar)//{
querySnapshot.forEach(doc=>{
console.log('TESTING@#@$'))

对于(让i=0;iany idea?我还尝试在comp上调用它以获得唯一的城市值,使用set而不是数组。问题是,查询中的forEach函数需要时间才能完成,然后当我尝试创建一些唯一的函数时,数组是空的。所以我简单地确定了是否要修复它。渲染的东西真的很烦人,有什么方法可以修复它吗或者刷新?有什么想法吗?我还尝试在comp-did-mount上调用它来获取唯一的城市值,使用set而不是数组。问题是,查询中的forEach函数需要时间才能完成,然后当我尝试创建一些唯一的函数时,数组是空的。所以我简化了是否修复它。渲染的东西真的很烦人,有什么方法吗强制刷新?
this.dbRef
            .where('Destination', '==', this.state.delegation)
          //  .orderBy('Location','desc')
            .get()
            .then(querySnapshot=> {
                querySnapshot.forEach(doc => {
                    console.log('TESTING@#@$')
                    for (let i=0; i<cityArr.length; i++) {
                        console.log('DOC.DATA.LOCATION = ',doc.data().Location , 'cityArr[i].city = ', cityArr[i].city )
                        if (doc.data().Location == cityArr[i].city) {
                            flag = 1;
                            break;
                        }
                    }
                    if (flag == 0)
                        cityArr.push({
                            City: doc.data().Location,
                        })
                    else
                        flag = 0;
                    console.log('CITY ARRAY:! ',cityArr)
                    i++;
                });
            })