当我在之前添加一个返回值时,我的平面列表似乎呈现出来,但是,这带来了一个问题,即我无法在平面列表中添加其他元素/组件(例如搜索栏)。它必须在列表中,因为我需要访问({item})。尝试弄乱它,但没有运气-谢谢您的帮助!
render(){
let something = this.props.resourceName.map(name => {
if (name.topic_id === this.props.route.params.topicId)
return name})
let anoda = something.filter(x => x !== undefined)
console.log(this.state)
return(
<View>
<Button title="Add A New Resource" onPress={() => this.props.navigation.navigate('Add A New Resource',{topicId:this.props.route.params.topicId})} style={styles.listitem} />
<FlatList style={styles.flatlist} keyExtractor={(item)=> item.name} data={anoda} ItemSeparatorComponent = { this.FlatListItemSeparator } renderItem={({item}) => {
<TouchableOpacity><Text onPress={() => this.props.navigation.navigate('Add A New Resource',{topicId:item.id})} style={styles.listitem}>{item.name}</Text><Button title="working?" onPress={()=>this.handlePress(item.id)}/></TouchableOpacity>
}
}
ListHeaderComponent = {this.header}/>
</View>
)
}
}