我正在 React Native 上开发一个应用程序。我创建了通知组件。我创建了两个未读和已读标签。单击通知会立即在 API 上读取。当我输入 FlatList 并且只有一项时,OnEndReachedThreshold 会自动工作。我不想要这个。如果数据大于 10,就让它工作。希望你能理解。我的英语不好,抱歉。
示例代码行
<FlatList
data={notifyReadData}
renderItem={({item}) =>
<ListItem
title={item.userName}
subtitle={Moment(item.createdAt, 'YYYY-MM-DD HH:mm:ss', true).add(3, 'hour').format("DD.MM.YYYY HH:mm")}
leftIcon={<Icon
name='bell-o'
size={24}
color='black'
/>}
bottomDivider={true}
/>
}
keyExtractor={this.keyExtractor}
refreshing={isRefreshing}
onRefresh={this.handleRefresh}
onEndReached={this.handleLoadMore}
onEndReachedThreshold={0.01}
/>
最佳答案
这是目前 RN 中非常普遍的问题。如果你谷歌它,有一些解决方案。其中之一是使用 onMomentumScrollBegin
<FlatList
data={notifyReadData}
renderItem={({item}) =>
<ListItem
title={item.userName}
subtitle={Moment(item.createdAt, 'YYYY-MM-DD HH:mm:ss', true).add(3, 'hour').format("DD.MM.YYYY HH:mm")}
leftIcon={<Icon
name='bell-o'
size={24}
color='black'
/>}
bottomDivider={true}
/>
}
keyExtractor={this.keyExtractor}
refreshing={isRefreshing}
onRefresh={this.handleRefresh}
onEndReached={this.state.scrolled && this.handleLoadMore()}
onEndReachedThreshold={0.01}
onMomentumScrollBegin={this.setState({scrolled: true})
/>
还有一种是自己实现onScroll。
关于javascript - 如何立即取消续订?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56684742/