javascript - React Native 无限滚动问题与少数元素

标签 javascript firebase react-native infinite-scroll

我正在使用 React Native 和 Firebase,并且尝试在 ListView 上使用无限滚动(加载更多),如果第一次获取可以填充屏幕整个高度的列表,则一切正常,因为 onEndReached 是触发,但是当元素很少并且屏幕上根本没有填充 ListView 时, onEndReached 不会触发,因此它不会下载并填充下一条记录。任何人都可以帮我处理这种情况吗? 提前致谢。

return (
        <View style={{flex:1}}>  
            <ListView
                dataSource={this.state.userDataSource}
                renderRow={this.renderRow.bind(this)}
                style={{paddingTop: 10, paddingBottom: 10}}
                enableEmptySections={true}
                renderFooter={this.renderFooter.bind(this)}
                onEndReached={this.infScrollFetch.bind(this)}
                onEndReachedThreshold={0.1}
                refreshControl={
                    <RefreshControl
                        refreshing={this.state.refreshing}
                        onRefresh={this._onRefresh.bind(this)}
                        title="Pull to refresh" tintColor="#fff" titleColor="#fff" colors={["#FEC200"]}
                    />
                }
                />
        </View>
      );

第一次获取是在 componentDidMount() 上调用的

最佳答案

尝试使用FlatList -> 它是无限列表的最佳元素。 (它还有不同的 onEndReachedThreshold 机制)

关于javascript - React Native 无限滚动问题与少数元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49937122/

相关文章:

javascript - 我如何有条件地在 Angular js中应用标题

android - FirebaseMessagingService 是否默认在后台运行?

android - 使用 play-services-xxx :9. 8.00 后 Firebase 错误无法访问 zzanb

ios - 在没有操作系统的情况下阅读 Apple 崩溃报告

javascript - 如何在React Native中调用带有来自另一个类的参数的函数?

javascript - 一个 html 按钮可以在按下时启动不同的 A HREF 吗?

javascript - 带有主干 Marionette 路由器的查询字符串

react-native - 无法运行 adb shell "date ` 日期 +%m%d%H%M%Y.%S`"

javascript - 无法安装插件添加phonegap-plugin-push ionic 3

android - 在 PHP 中保存用户 ID 的 session 的等价物是什么?