Javascript 反应本机映射和显示对象数组

Javascript 反应本机映射和显示对象数组,javascript,react-native,google-cloud-firestore,expo,Javascript,React Native,Google Cloud Firestore,Expo,除非从阵列列表映射中取出,否则不显示具有卡片样式的视图 我的代码有问题吗? reslit是一个从firestore数据库读取数据的数组 下面是阵列的控制台日志 被困在这里已经三天没露面了 [在此处输入图像描述][1] const db = firebase.firestore(); var reslist = []; db .collection('Rests') .get() .then(querySnapshot => { querySnapshot.forE

除非从阵列列表映射中取出,否则不显示具有卡片样式的视图 我的代码有问题吗? reslit是一个从firestore数据库读取数据的数组 下面是阵列的控制台日志 被困在这里已经三天没露面了 [在此处输入图像描述][1]

const db = firebase.firestore();
var reslist = [];

  db
  .collection('Rests')
  .get()
  .then(querySnapshot => {
    querySnapshot.forEach(doc => {
      reslist.push({
        name:doc.data().name,
        description:doc.data().description,
        title:doc.data().title,
        rating:doc.data().rating,
        open:doc.data().open,
        close:doc.data().close,
        location:doc.data().location,
       // menu:doc.data().menu,
    })
    console.log(reslist)
    //console.log(doc.data().menu)
    });
  });
return(
{
             reslist.map( Res => 
          <TouchableOpacity onPress={()=>{navigation.navigate("Details",Res.id)}}>
          <View style={styles.card}>
            <View style={styles.cardImgWrapper}>
              <Image
                source={require('./../../assets/food-banner1.jpg')}
                resizeMode="cover"
                style={styles.cardImg}
                />
            </View>
            <View style={styles.cardInfo}>
              <Text style={styles.cardTitle}>{Res.title}</Text>
              <StarRating ratings={Res.rating} reviews={350} />
              <Text style={styles.cardDetails}>
                {Res.description}
              </Text>
            </View>
          </View>
          </TouchableOpacity> 
         )
              }
)
const db=firebase.firestore();
var reslist=[];
分贝
.collection('Rests')
.get()
.然后(querySnapshot=>{
querySnapshot.forEach(doc=>{
reslist.push({
名称:doc.data().name,
description:doc.data().description,
标题:doc.data().title,
评级:doc.data().rating,
打开:doc.data().open,
关闭:doc.data().close,
位置:doc.data().location,
//菜单:doc.data()菜单,
})
console.log(reslist)
//console.log(doc.data()菜单)
});
});
返回(
{
reslist.map(Res=>
{navigation.navigate(“Details”,Res.id)}>
{Res.title}
{Res.description}
)
}
)
阵列的控制台日志:

排列[

反对{ “结束”:“23”, “描述”:“皇家餐厅描述…”, “地点”:t{ “U”:33.853366, “k”:10.102713, }, “姓名”:“皇家”, “开放”:10, “评级”:4, “头衔”:“餐厅”, }, 反对{ “结束”:23, “说明”:“我们必须添加…以避免仅在具有多个菜单的setails屏幕中显示”, “地点”:t{ “U”:33.850653, “k”:10.106268, }, “名称”:“远东”, “开放”:7, “评级”:5, “标题”:“咖啡”, }, ]

下面是数据结构 [1] :

试试这个方法

function Example() {

 const [reslist, setReslist] = useState([]);

 useEffect(() => {
   getFireBaseData();
 });

 const getFireBaseData = () => {

   const db = firebase.firestore();
   var reslistData = [];

   db
   .collection('Rests')
   .get()
   .then(querySnapshot => {
    querySnapshot.forEach(doc => {
      reslistData.push({
        name:doc.data().name,
        description:doc.data().description,
        title:doc.data().title,
        rating:doc.data().rating,
        open:doc.data().open,
        close:doc.data().close,
        location:doc.data().location,
       // menu:doc.data().menu,
     })
    });
  });
  
  setReslist(reslistData); // this will reflect on view

 }

 return( { 
       reslist.map( Res => ...)
     })
}

你能帮我们粘贴一下
reslist.map(Res=>console.log(Res))
的每个元素都有什么吗?给你