简体   繁体   English

搜索返回0个结果时,不调用带有搜索的平面列表onEndReached

[英]Flatlist with search, onEndReached is not called when search return 0 results

I have a flatlist which fetch data from a remote server, the flatlist have pagination implemented and a linked search functionality. 我有一个可从远程服务器获取数据的清单,该清单已实现分页和链接的搜索功能。 OnEndReached is called when I hit the end of the list and the next page is loaded, the same thing happen when I search through the list and one or more record is found that matchs the search criteria. 当我点击列表的末尾并加载下一页时,将调用OnEndReached,当我搜索列表并发现一个或多个符合搜索条件的记录时,也会发生同样的事情。 However when I search through the list and there is 0 result matching the search from the already loaded records, in this case onEndReached is not called at all. 但是,当我搜索列表时,有0个匹配已加载记录中搜索结果的结果,在这种情况下,根本不会调用onEndReached。 I tried different value for the onendreachedthreshold but prop without success. 我为onendreachedthreshold尝试了不同的价值,但没有成功就支持了。 Do you have any idea why is this happening. 您知道为什么会这样吗? Thanks 谢谢

onEndReached is called when the end of the view of the FlatList is within the range of the onEndReachedThreshold . onEndReached视图的末端在onEndReachedThreshold范围内时,将onEndReachedThreshold

In the case where 0 results are displayed, the view of the FlatList would be within the visible screen area (ie no scrolling), hence, onEndReached won't be called. 在显示0个结果的情况下,FlatList的视图将在可见的屏幕区域内(即,没有滚动),因此,不会调用onEndReached That's how onEndReached works. 这就是onEndReached工作方式。

PS If you're trying to display a message when 0 results are displayed, you should try calling it when the results are fetched and the page 1 is empty. PS如果尝试在显示0结果时显示消息,则应在获取结果且页面1为空时尝试调用该消息。 Since I don't exactly know what you're trying to do, I can't suggest you the best solution. 由于我不完全了解您要做什么,因此我无法为您提供最佳解决方案。 Try explaining a bit more maybe. 尝试多解释一些。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM