Javascript Firestore查询错误:对象作为子对象无效

Javascript Firestore查询错误:对象作为子对象无效,javascript,reactjs,firebase,react-native,google-cloud-firestore,Javascript,Reactjs,Firebase,React Native,Google Cloud Firestore,我正在尝试从firestore进行查询:我想将收集任务中具有相同字段ID的所有字段放入Clients/1/任务(位于firestore和查询代码下方) 我尝试过这样做,但我有一个错误: 对象作为React子对象无效(找到:键为{U,{U V,{U W,{U X}的对象)。如果要呈现子对象集合,请改用数组 这是我的代码: const GoalScreen = async (props) => { IDUserNum = 1; IDUser = IDUserNum.toString()

我正在尝试从firestore进行查询:我想将收集任务中具有相同字段ID的所有字段放入Clients/1/任务(位于firestore和查询代码下方)

我尝试过这样做,但我有一个错误:

对象作为React子对象无效(找到:键为{U,{U V,{U W,{U X}的对象)。如果要呈现子对象集合,请改用数组

这是我的代码:

const GoalScreen = async (props) => {
  IDUserNum = 1;
  IDUser = IDUserNum.toString();
  if (IDUser) {
    const array = [];
    const a = await firebase.firestore().collection('Clients').doc(IDUser).collection('Missions').get();
    if(!a) {
      return(
        <View><Text>ciao</Text></View>
      )
    }
    a.forEach((IDMission) => {
      const b = a.doc(IDMission).get().ID_Mission;
      const c = firebase.firestore().doc(b).data();
      array.push[c];
      console.log(c);
    })
      return (
        <View style={styles.container}>
  
        <Text style={styles.loginText}>Here the should be the goals</Text>
  
        </View>
      );
  } 
  return (
    <View><Text>orso</Text></View>
  )
}

const goalsscreen=async(props)=>{
IDUserNum=1;
IDUser=IDUserNum.toString();
if(IDUser){
常量数组=[];
const a=wait firebase.firestore().collection('Clients').doc(IDUser.collection('Missions').get();
如果(!a){
返回(
再见
)
}
a、 forEach((IDMission)=>{
const b=a.doc(IDMission).get().ID\u任务;
常数c=firebase.firestore().doc(b.data();
array.push[c];
控制台日志(c);
})
返回(
这里应该是目标
);
} 
返回(
奥索
)
}
这里是火场


哦,好的,有了额外的数据,我可以帮上一点忙。问题是使用forEach时,它不会返回任何内容,因此组件不会接收任何要渲染的内容。尝试使用.map,您至少应该解决第一个错误。

我认为这个错误不是由firebase造成的。错误表示react无法呈现对象,因为它只接受JSX元素。您能告诉我们您在哪里使用从firebase检索到的数据吗?还有,你能把它记录下来吗?这样我们就可以看到错误发生的地方,以及你是否正确地接收到数据。我还没有使用它们,我只是想做一些测试。无论如何,我用函数的完整代码和错误屏幕更新了问题。我很难理解您想要做什么查询。为了更好地理解,你能用其他的话解释一下吗?我试着这么做,但仍然不起作用:a.map((IDMission)=>{const b=a.doc(IDMission).get().ID_Mission;const c=firebase.firestore().doc(b).data();array.push[c];console.log(c);})