【问题标题】:Undefined is not a function near setIntervalundefined 不是 setInterval 附近的函数
【发布时间】:2019-09-28 19:06:22
【问题描述】:

我在 onPressed 上导入一个函数,但每次我按下图标时都会出现错误:“未定义不是 setInterval 附近的函数”。请解决。

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);
      }
      }
          />

【问题讨论】:

    标签: ecmascript-6 react-native-android


    【解决方案1】:

    你有一个 .在您需要删除的 setInterval 之前。

    //now fetching the response from the yt api again and again 
    setInterval(() =>
    ...
    

    【讨论】:

      猜你喜欢
      • 2019-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-12
      • 2015-10-29
      • 2015-06-05
      • 2019-10-16
      相关资源
      最近更新 更多