如何在 react-native 中下载文件?

How can I download a file in react-native?

我 运行 在我的控制台中执行此命令 npm install react-native-fs --save 然后在我的 onclick 函数中加入这段代码

 _download =  (downloadpath) => {
  // console.log(introduction);
var RNFS = require('react-native-fs');

   try {

    RNFS.downloadFile({
        fromUrl: downloadpath,
        toFile: `${RNFS.DocumentDirectoryPath}/test.zip`,
      }).promise.then((r) => {
        this.setState({ isDone: true })
      });

} catch (error) {

   console.log(error);
  // Error saving data
}


  }

但它给出了这个

嗯,不幸的是,RNFS 与 expo 不兼容,因为它包装了本机库。您通常可以在 http://native.directory

中查看