【发布时间】:2021-06-22 12:32:20
【问题描述】:
我正在使用 React Native 构建一个移动应用程序,其中一个页面中有一个 ScrollView。
问题是我在这个页面中有一个FlatList,所以当我转到那个页面时,我收到了这个错误:
VirtualizedLists should never be nested inside plain ScrollViews with the same orientation... 问题是,我将ScrollView nestedScrollEnabled 设置为true,我还将FlatList's scrollEnabled 设置为false,因为我真的不需要那里的滚动(我用它来渲染枚举中的项目)所以我认为应该修复错误,但错误仍然存在。
看起来像这样:
<ScrollView showsVerticalScrollIndicator={false} nestedScrollEnabled={true}>
<MyComponent />
</ScrollView>
MyComponent 有这个 FlatList:
<FlatList
scrollEnabled={false}
style={{padding: 8,marginBottom: 8,}}
data={categories}
numColumns={numOfColumns}
keyExtractor={category => category}
renderItem={item => renderItem(item.item)}
/>
它基本上看起来像这样:
<SafeAreaView>
<ScrollView>
<FlatList />
<OTHER COMPONENTS />
</ScrollView>
</SafeAreaView>
【问题讨论】:
标签: react-native