【发布时间】:2019-11-04 16:42:00
【问题描述】:
我有一个简单的提要,我使用 FlatList 加载帖子,并且它还有在达到某个点后加载的页面。有一段时间,它运行良好,完美加载页面,但几页后,它开始出现故障,有时会消失。
我上传了这个关于问题的 GIF https://i.stack.imgur.com/zPhkg.gif
<SafeAreaView style={Common.container}>
<FlatList
ref={ref => {
this.flatListRef = ref;
}}
ListEmptyComponent={<LandingImage />}
showsVerticalScrollIndicator={false}
data={this.state.dataSource}
onEndReached={()=> handleLoadMore(this)}
onEndReachedThreshold={0.5}
onRefresh={() => handleRefresh(this)}
refreshing={this.state.refreshing}
ItemSeparatorComponent={RenderSeparator}
renderItem={({item, index}) => this.renderData(item, index)}
keyExtractor={({item, index}) => index}
/>
<NewPost
goCreatePost={() =>
this.props.navigation.navigate('CreatePost', {
edit: false,
refresh: () => handleRefresh(this),
screen: 'Home',
})
}
/>
</SafeAreaView>
【问题讨论】:
-
增加 onEndReachedThreshold
标签: reactjs react-native react-native-flatlist