【发布时间】:2020-07-03 05:12:27
【问题描述】:
当我尝试在 View 中使用 Flatlist 时收到此警告,但出现同样的错误:
VirtualizedLists should never be nested inside plain ScrollViews with the same orientation - use another VirtualizedList-backed container instead.
我在里面使用 FlatList 的组件是:
class About extends Component
{
constructor(props)
{
super(props);
this.state = {
leaders: LEADERS
};
}
render(){
const renderLeaders = ({item,index}) => {
return(
<ListItem
key = {index}
title = {item.name}
subtitle = {item.description}
hideChevron = {true}
leftAvatar = {{ source: require('./images/alberto.png') }}
/>
);
};
return(
<ScrollView>
<History />
<Card title = "Corporate Leadership">
<FlatList
data = {this.state.leaders}
renderItem = {renderLeaders}
keyExtractor = {item => item.id.toString()}
/>
</Card>
</ScrollView>
);
}
}
我可以在这里使用leader 代替item 吗?我尝试使用它,但出现错误。
【问题讨论】:
标签: react-native scrollview react-native-android react-native-flatlist