Ios 任何滚动事件(如onScroll)都不适用于FlatList组件
因此,我有一个在iOS上使用React Native的项目,使用Ios 任何滚动事件(如onScroll)都不适用于FlatList组件,ios,react-native,react-native-flatlist,Ios,React Native,React Native Flatlist,因此,我有一个在iOS上使用React Native的项目,使用组件,如果购物车数据在如下视图下为空,则使用函数renderContent()有条件地呈现该组件: <SafeAreaView style={styles.container}> <Navigator.Config onAppear={this.handleGetData} onDisappear={this.handleOnDisappear} rightButtons
组件,如果购物车数据在如下视图下为空,则使用函数renderContent()
有条件地呈现该组件:
<SafeAreaView style={styles.container}>
<Navigator.Config
onAppear={this.handleGetData}
onDisappear={this.handleOnDisappear}
rightButtons={deleteButton}
onRightPress={this.handleDeleteButton}
>
{this.renderContent()}
</Navigator.Config>
</SafeAreaView>
}
组件
<View style={{ flex: 1, backgroundColor: 'white' }}>
<View>
<View style={{ paddingTop: noLogin ? 50 : 30, alignItems: 'center' }}>
...
{
cartData.isLoadingRecommended == false ?
<SuggestionsView title="Rekomendasi"
data={cartData.recommended ? cartData.recommended.recommendation : []}
renderItem={renderItemRecommended}
onScroll={handleScroll}
onEndReached={(info)=>{
// if(!cartData.isLoadingRecommended && cartData.recommended){
console.log('----------** END **------------', info, cartData.isLoadingRecommended)
// }
}}
/>
:
<ActivityIndicator animating size="small" />
}
</View>
...
{
cartData.IsLoadingRecommendated==false?
{
//如果(!cartData.isLoadingRecommended&&cartData.recommended){
console.log('----------**END**-------------',info,cartData.isLoadingRecommended)
// }
}}
/>
:
}
而
组件在内部呈现`
import { View, Text, Image, FlatList, TouchableOpacity } from 'react-native'
import React, { Component } from 'react'
import Icon from 'react-native-vector-icons/EvilIcons'
import { ReactTPRoutes } from 'NativeModules'
class SuggestionsView extends Component {
constructor(props){
super(props)
this.state = {
isRefreshing: false,
isLoading: false,
isLoadingMorePost: true,
hasNextPage: false,
reachFeedEnd: false,
shouldDisplayErrorToaster: false,
isError: false,
}
}
handlePressViewAll = () => this.props.onPressViewAll()
keyExtractor = (item, index) => index;
render(){
return (
<View style={{
paddingLeft: 16,
paddingRight: 16,
}}>
</View>
<FlatList
style={{ flex: 1 }}
numColumns={2}
data={this.props.data}
keyExtractor={this.keyExtractor}
renderItem={this.props.renderItem}
onEndReachedThreshold={0.3}
scrollEventThrottle={16}
onEndReached={(info)=>{
if(this.props.onEndReached){
this.props.onEndReached(info)
}
}}
ref={x => {
this.flatist = x // tslint:disable-line
}}
onScroll={()=> console.log('test')}
/>
</View>
)}
}
从'react native'导入{视图、文本、图像、平面列表、TouchableOpacity}
从“React”导入React,{Component}
从“反应本机矢量图标/图标”导入图标
从“NativeModules”导入{reactroutes}
类SuggestionView扩展组件{
建造师(道具){
超级(道具)
此.state={
isRefreshing:错,
孤岛加载:false,
isLoadingMorePost:是的,
hasNextPage:错误,
reachFeedEnd:false,
shouldDisplayErrorToaster:错误,
伊瑟罗:错,
}
}
handlePressViewAll=()=>this.props.onPressViewAll()
keyExtractor=(项,索引)=>索引;
render(){
返回(
{
如果(此.props.onEndReached){
此.props.onEndReached(信息)
}
}}
ref={x=>{
this.flatist=x//tslint:禁用行
}}
onScroll={()=>console.log('test')}
/>
)}
}
导出默认建议视图
尽管由于某种原因,onScroll
方法根本没有启动。由于某种原因,scrollToEnd
方法也没有启动。谢谢你的帮助
import { View, Text, Image, FlatList, TouchableOpacity } from 'react-native'
import React, { Component } from 'react'
import Icon from 'react-native-vector-icons/EvilIcons'
import { ReactTPRoutes } from 'NativeModules'
class SuggestionsView extends Component {
constructor(props){
super(props)
this.state = {
isRefreshing: false,
isLoading: false,
isLoadingMorePost: true,
hasNextPage: false,
reachFeedEnd: false,
shouldDisplayErrorToaster: false,
isError: false,
}
}
handlePressViewAll = () => this.props.onPressViewAll()
keyExtractor = (item, index) => index;
render(){
return (
<View style={{
paddingLeft: 16,
paddingRight: 16,
}}>
</View>
<FlatList
style={{ flex: 1 }}
numColumns={2}
data={this.props.data}
keyExtractor={this.keyExtractor}
renderItem={this.props.renderItem}
onEndReachedThreshold={0.3}
scrollEventThrottle={16}
onEndReached={(info)=>{
if(this.props.onEndReached){
this.props.onEndReached(info)
}
}}
ref={x => {
this.flatist = x // tslint:disable-line
}}
onScroll={()=> console.log('test')}
/>
</View>
)}
}