【问题标题】:React Native infinite scroll problems with few elements元素很少的 React Native 无限滚动问题
【发布时间】:2018-04-20 08:15:55
【问题描述】:

我正在使用带有 Firebase 的 React Native,并且我正在尝试在我的 Listview 上使用无限滚动(加载更多),如果第一次获取可以填充整个屏幕高度的列表,那么一切正常,因为 onEndReached 是但是当元素很少并且屏幕上根本没有填充列表视图时,不会触发 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>
      );

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

【问题讨论】:

    标签: javascript firebase react-native infinite-scroll


    【解决方案1】:

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

    【讨论】:

    • 它有效,我没有得到这两个 onEndReachedThreshold 之间的差异。感谢您的帮助!
    猜你喜欢
    • 1970-01-01
    • 2016-01-26
    • 1970-01-01
    • 2012-02-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多