大佬教程收集整理的这篇文章主要介绍了ReactNative Flatlist onEndReached不起作用,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
您在FlatList中寻找的属性是onEndReachedThreshold而不是onEndThreshold。
我试图在onEndReached
FlatList 上调用函数,但无法正常工作。
我在最后打电话给我this.state.pageNo
,它没有更新。我想稍后在无限滚动中使用此逻辑,但现在无法使其工作。
import React,{ Component } from "react";
import {
View,Text,StyleSheet,Button,TouchabLeopacity,FlatList,Alert
} from "react-native";
class InfiniteScrollRedux extends Component {
constructor(props) {
super(props);
this.state = {
loading: false,pageNo: 1,data: [
{ id: 1,name: "Name01" },{ id: 2,name: "Name02" },{ id: 3,name: "Name03" },{ id: 4,name: "Name04" },{ id: 5,name: "Name05" },{ id: 6,name: "Name06" }
]
};
}
MyFunction = () => {
this.setState({ pageNo: this.state.pageNo++ });
};
render() {
return (
<View>
<FlatList
data={this.state.data}
renderItem={({ item }) => (
<View style={mystyle.mainCarD}>
<Text style={mystyle.titleText}> {item.iD} </Text>
<View style={{ marginTop: 200 }} />
<Text style={mystyle.nameText}> {item.namE} </Text>
</View>
)}
keyExtractor={item => item.iD}
onEndReached={this.MyFunction}
onEndThreshold={0}
/>
<Text style={{ margin: 20,padding: 20,fontSize: 20 }}>
{this.state.pageNo}
</Text>
</View>
);
}
}
const mystyle = StyleSheet.create({
mainCard: {
BACkgroundColor: "#2F4F4F",marginBottom: 1,padding: 5
},titleText: {
fontSize: 20,color: "#F0FFFF"
},nameText: {
fontSize: 14,color: "#F0FFFF"
}
});
export default InfiniteScrollRedux;
以上是大佬教程为你收集整理的ReactNative Flatlist onEndReached不起作用全部内容,希望文章能够帮你解决ReactNative Flatlist onEndReached不起作用所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。