React Native:列表的呈现不起作用

React Native: Rendering of List not working

我目前遇到了在 react-native 中呈现列表的问题。 此代码仅呈现 cards 数组的第一个数组元素,而不是所有数组条目。 我错过了什么吗?

卡片数组示例:

const cards = [{"created_at": "2022-01-25 20:07:14", "description": "Descriptiontext", "id": 1, "title": "Titel 1", "updated_at": "2022-02-25 07:41:18.304291", "userid_fk": 2}, {"created_at": "2022-01-25 20:07:14", "description": "Descriptiontext 2", "id": 2, "title": "Titel 2", "updated_at": "2022-02-25 07:41:18.304291", "userid_fk": 2}]
<ScrollView>
                {cards.map((element: any) => (
                  <Layout
                    key={element.id}
                    style={[
                      globalStyles.container,
                      {flexDirection: 'row', justifyContent: 'space-between'},
                    ]}>
                    <Layout>
                      <Text style={element.title} numberOfLines={1}>
                        {element.title}
                      </Text>
                      <Text
                        style={styles.desc}
                        ellipsizeMode={'tail'}
                        numberOfLines={1}
                        lineBreakMode="tail">
                        {element.description}
                      </Text>
                      <Text appearance={'hint'} style={styles.date}>
                        Erstellt am:{' '}
                        {moment(String(element.created_at)).format(
                          'DD.MM.YYYY HH:mm',
                        )}
                      </Text>
                    </Layout>
                    <TouchableOpacity
                      onPress={() => deleteCard(element.id)}>
                      <Icon
                        name="trash"
                        fill={silver}
                        style={globalStyles.icon}
                      />
                    </TouchableOpacity>
                  </Layout>
                ))}
 </ScrollView>

这里是一个使用地图的例子,我提供了一些代码以及一个工作小吃博览会here

const Screen3 = (props) => {
  const renderList = (props) => {
    return List.map((item, i) => {
      return (
        <View style={{ paddingLeft: scale(10), paddingRight: scale(10), paddingTop: scale(20) }}>
          <View
            style={{
              backgroundColor: 'white',
              width: scale(330),
              height: scale(85),
              borderRadius: scale(10),
            }}>
            <Text>{item.name}</Text>
          </View>
        </View>
      );
    });
  };

 return (
    <View style={{ backgroundColor: '#d1cfcf' }}>
        <ScrollView style={{ height: 1000 }}>{renderList()}</ScrollView>
      </View>
    </View>
  );
};