React Native fetch不是一个函数

Man*_*tro 2 react-native fetch-api

我正在尝试使用本机响应简单的应用程序.我想从页面下载一个json数组并将其显示为listview.我这样做

var listApp = React.createClass({

fetchData : function() {
  fetch(requestURL)
    .then((response) => response.json())
    .then((responseData) => {
      console.log(responseData);
    })
    .done();
},
componentDidMount: function() {
  this.fetchData();
  this.setState({
    dataSource: this.state.dataSource.cloneWithRows(elements)
  });
},
Run Code Online (Sandbox Code Playgroud)

但是这样做我fetch is not a function从Chrome调试器中得到了错误.我以这种方式获取var fetch = require("fetch");

Col*_*say 5

你不需要require它.它是浏览器版本的polyfill,与浏览器版本一样,它始终可用于全局范围.