我在其中使用 Flatlist 制作了一个组件 EventCards。我在 Home 组件中调用该组件,其中 EventCards 组件位于 ScrollView 中。
Const Home= () => {
return (
othercomponents...
<ScrollView>
othercomponents...
<EventCards />
othercomponents...
</ScrollView>
othercomponents...
)
}
现在,它给出了一个错误:
VirtualizedLists should never be nested inside plain ScrollViews with the same orientation because it can break windowing and other functionality - use another VirtualizedList-backed container instead.
我尝试在 Scrollview 中使用 FlatList。但它抛出一个错误。我想解决这个错误。
正如明确指出的,你不应该将 FlatList 嵌套在 ScrollView 中。
现在,如果您希望当用户在视口内滚动时在 FlatList 之前或之后看到 ScrollView 内的其他组件,您可以分别使用 ListHeaderComponent 和 ListFooterComponent,然后从代码中删除 ScrollView。
如果这不是您正在寻找的答案,请提供有关您计划实现的 UI 的更多信息。