Ecmascript 6 Undefined不是setInterval附近的函数
我在onPressed上导入一个函数,但每次按下图标时,它都会给我一个错误:“undefined不是setInterval附近的函数”。请解决它Ecmascript 6 Undefined不是setInterval附近的函数,ecmascript-6,react-native-android,Ecmascript 6,React Native Android,我在onPressed上导入一个函数,但每次按下图标时,它都会给我一个错误:“undefined不是setInterval附近的函数”。请解决它 onPressedButton = channelId => // fetch the value entered in the input field //alert(channelId); this.setState({channelId:channelId}) //fetch the value(channelId) that is
onPressedButton = channelId =>
// fetch the value entered in the input field
//alert(channelId);
this.setState({channelId:channelId})
//fetch the value(channelId) that is enter in the input field
// make a request
var url = 'https://www.googleapis.com/youtube/v3/channels?key='+API_key+'&id=' + this.state.channelId + '&part=snippet,contentDetails,statistics';
this.setState({url: url});
fetch(url,{
method: 'GET'
})
.then((response) =>
response.json())
// fetchData(data);
alert('calling2');
})
//now fetching the response from the yt api again and again
.setInterval(() =>
{
var url = 'https://www.googleapis.com/youtube/v3/channels?key='+API_key+'&id=' + this.state.channelId + '&part=statistics';
fetch(url,{
method: 'GET'
})
.then((response) => updateSubscribers(response.json()))
},0)
.catch((error) => {
console.log(error);
});
}
从中导入此文件的文件:
<Icon style = {styles.icon}
name = 'search'
type = 'material'
color= 'black'
onPress = {() => {
this.setState({channelId: this.getChannelId(this.state.term)});
obj.onPressedButton(this.state.channelId);
}
}
/>
{
this.setState({channelId:this.getChannelId(this.state.term)});
obj.ON按下按钮(此.state.channelId);
}
}
/>
您有一个。在需要删除的设置间隔之前
//now fetching the response from the yt api again and again
setInterval(() =>
...