React Native无限滚动问题,几个元素

时间:2018-04-20 08:15:56

标签: javascript firebase react-native infinite-scroll

我正在使用React Native和Firebase,我正在尝试在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>
      );

第一次获取是在componentDidMount()

上调用的

1 个答案:

答案 0 :(得分:1)

尝试使用FlatList - &gt;它是无限列表的最佳元素。 (它还有onEndReachedThreshold

的不同机制