React native Can';t在平面列表中渲染对象数组

React native Can';t在平面列表中渲染对象数组,react-native,React Native,我有一个虚拟数据数组: const DUMMY_DATA = [ { id: '1', subject: 'SUBJECT1', creator: 'CREATOR1', max_participants: '34', location: 'location', date: 'date', }, { id: '2', subject: 'SUBJECT1', creator: 'CREATOR1', max_part

我有一个虚拟数据数组:

const DUMMY_DATA = [
{
    id: '1',
    subject: 'SUBJECT1',
    creator: 'CREATOR1',
    max_participants: '34',
    location: 'location',
    date: 'date',
},
{
    id: '2',
    subject: 'SUBJECT1',
    creator: 'CREATOR1',
    max_participants: '34',
    location: 'location',
    date: 'date',
},
{
    id: '3',
    subject: 'SUBJECT1',
    creator: 'CREATOR1',
    max_participants: '34',
    location: 'location',
    date: 'date',
},
]
我有一个组件,它获取对象并渲染它

这就是我现在拥有的:

const Item = ({ meeting }) => (
    <TouchableOpacity style={styles.cardButton} onPress={this._showMeetingDetails}>
        <MeetingCard meetingModel={meeting} />
    </TouchableOpacity>
);

const HomeScreen = ({ navigation }) => {
    _showMeetingDetails = () => {
        navigation.navigate('MeetingDetails', { meeting: meeting });
    }


    const renderItem = ({ meeting }) => (
        <Item meeting={meeting} />
    );

    return (
        <>
            <SafeAreaView style={styles.homeContainer}>
                <View>
                    <View style={styles.headerContainer}>
                        <View style={{ display: "flex", flexDirection: "row", justifyContent: "space-between", alignItems: "center" }}>
                            <Text style={styles.title}>Groups</Text>
                            <Avatar
                                rounded
                                source={{
                                    uri:
                                        'https://s3.amazonaws.com/uifaces/faces/twitter/ladylexy/128.jpg',
                                }}
                            />
                        </View>
                        <Text style={styles.subtitle}>Find people to learn with</Text>
                    </View>
                    <OptionChooser />


                  <FlatList
                      data={DUMMY_DATA}
                      renderItem={renderItem}
                      keyExtractor={item => item.id}
                  />


                </View>
                <FloatingButton onPress={this._showAddMeeting} />
            </SafeAreaView>
        </>
    )
}
我想在一个平面列表中呈现这个,我尝试了我找到的每一个解决方案,但我不明白为什么它对我不起作用。我知道我通过的是未定义的meetingModel,但我不知道原因是什么。我尝试了一些在平面列表中呈现对象数组的解决方案,但对我来说不起作用-我真的不知道我做错了什么(我是新来的本地人)

这是我的MeetingCard组件,以防需要(我认为不需要它,因为问题是我将未定义的内容传递给它):

const MeetingCard=(道具)=>{
返回(
{props.meetingModel.subject}
创建人:{props.meetingModel.creator}
计划于:{props.meetingModel.date}
最大人数:{props.meetingModel.max_participants}人
)
}
使用键名
索引
分隔符
获取对象。由于在
renderItem
中没有
会议
键,因此未定义会议。我想如果你把它从

const renderItem = ({ meeting }) => (
    <Item meeting={meeting} />
);
const renderItem=({meeting})=>(
);

const renderItem=({item:meeting})=>(
);
那应该行


祝你好运

问题在于您正在以对象作为键访问的项函数中。。尝试更改常量项=(会议)=>{}
const MeetingCard = (props) => {
return (
    <View style={styles.card}>
        <View>
            <Text style={styles.subject}>
                {props.meetingModel.subject}
            </Text>
            <Text style={styles.creator}>
                Created By: {props.meetingModel.creator}
            </Text>
        </View>
        <View>
            <View style={styles.separator}></View>
            <View style={styles.infoRow}>
                <Icon name="time-outline" size={24} color="#000" />
                <Text style={{ marginVertical: 4, marginHorizontal: 8 }}>Scheduled to: {props.meetingModel.date}</Text>
            </View>
            <View style={styles.infoRow}>
                <Icon name="people-outline" size={24} color="#000" />
                <Text style={{ marginVertical: 4, marginHorizontal: 8 }}>Maximum of: {props.meetingModel.max_participants} people</Text>
            </View>
        </View>
    </View>
)
}
const renderItem = ({ meeting }) => (
    <Item meeting={meeting} />
);
const renderItem = ({ item: meeting }) => (
    <Item meeting={meeting} />
);