I re-call this._fetchData ()
when I load more data _ fetchMoreData ()
. Why do I report "this._fetchData () is not a function ()"
componentDidMount(){
this._fetchData(1)
}
//
_fetchData(page) {
const that = this
//,isLoadingDatastatetrue;
//isRefreshingstatetrue
if(page !== 0){
this.setState({
isLoadingData: true
})
}else{
this.setState({
isRefreshing: true
})
}
try {
//request.get("http://www.rapapi.org/mockjs/33254/api/list?accessToken=labike&page=10")
request.get(Config.api.baseUrl + Config.api.list, {
accessToken: "labike",
page: page
})
}
_fetchMoreData(){
// if(!this._hasMoreData || this.state.isLoadingData){
// return
// }
const page = cacleResult.nextPage
console.log(page)
this._fetchData(page)
}
render(){
return(
<View style={styles.container}>
<View style={styles.header}>
<Text style={styles.headerTitle}>Header</Text>
</View>
<ListView
dataSource={this.state.dataSource}
renderRow={this._renderItem}
renderFooter={this._renderFooter}
refreshControl={
<RefreshControl
refreshing={this.state.isRefreshing}
onRefresh={this._onRefresh}
tintColor="-sharpff0000"
title="Loading..."
/>
}
onEndReached={this._fetchMoreData}
onEndReachedThreshold={20}
showsVerticalScrollIndicator={false}
enableEmptySections={true}
/>
</View>
)
}